Tell us what’s happening:
Describe your issue in detail here.
All the calls from the rot13 decipher challenge output the expected result, but none of the calls actually pass …
I’ve tried the option to reset the code many times.
Examples:
rot13("SERR PBQR PNZC")
should decode to the string FREE CODE CAMP
rot13("SERR CVMMN!")
should decode to the string FREE PIZZA!
rot13("SERR YBIR?")
should decode to the string FREE LOVE?
rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.")
should decode to the string THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
**Your code so far**
function rot13(str) {
const alphabet = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"];
let rot = [...str];
let cipher = [];
for (let i = 0; i < rot.length; i++){
let newIndex = alphabet.indexOf(rot[i]);
if(alphabet.indexOf(rot[i]) == -1){
cipher.push(rot[i]);
} else {
cipher.push(alphabet[newIndex + 13]);
}
}
return cipher.join(" ");
}
console.log(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/93.0.4577.63 Safari/537.36
Challenge: Caesars Cipher
Link to the challenge: