Caesars Cipher freecodecamp project

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

Your code so far


function rot13(str) {
let decodedResult = "";
let alphabetStart ="abcdefghijklm".toUpperCase();
let alphabetEnd ="nopqrstuvwxyz" .toUpperCase();

for (let i = 0; i < str.length; i += 1) {
let letterToDecode = str[i];

if (alphabetStart.index0f(letterToDecode) >= 0) {
decodedResult += alphabetEnd [alphabetStart.indexOf(letterToDecode)];
} else if (alphabetEnd.indexOf(letterToDecode) >= 0) {
decodedResult += alphabetStart [alphabetEnd.indexOf(letterToDecode)];
} else {
decodedResult += letterToDecode;
}
}
return decodedResult;
}
let result = rot13("SERR PBQR PNZC");
console. log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 11; vivo 1906) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.88 Mobile Safari/537.36

Challenge: Caesars Cipher

Link to the challenge:

What is your question? With what exactly do you need help?

1 Like

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