JavaScript Algorithms and Data Structures Projects - Caesars Cipher

Tell us what’s happening:
Describe your issue in detail here.

I’m getting a “ReferenceError: isALetter is not defined” any ideas…what am I missing.

  **Your code so far**
const alphabet = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z"
];

function rot13(str) {
let accumulator = "";
for (var i = 0; i < str.legnth; i++) {
  const char = str[i];
  const isALetter = alphabet.includes(char);
}

if (isALetter === false) { accumulator += char; }
else { const charIndex = alphabet.findIndex((c) => c === char);
accumulator += alphabet[charIndex + 13] || alphabet[charIndex - 13];}

return accumulator;

}

rot13("SERR PBQR PNZC");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Caesars Cipher

Link to the challenge:

That variable only exists inside of your for loop.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.