function rot13(str) { // LBH QVQ VG!
var arr = [];
for(var i = 0; i < str.length; i++)
{
if(str.charAt(i) != ' ')
{
arr[i] = String.fromCharCode(str.charCodeAt(i) - 13);
}
else
{
arr[i] = ' ';
}
}
str = arr.join('');
return str;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
This results in “F8EE C5DE CAM6”.
I’m going to take a wild guess and say that it’s supposed to print FREE CODE CAMP. Why it wouldn’t decipher the R, O, or P is beyond me. Any ideas?