Tell us what’s happening:
Your code so far
function rot13(str) {
var arr = str.split(" ");
var newArr = [];
var temp = 0;
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr[i].length; j++){
if(arr[i].charCodeAt(j) >= 78 && arr[i].charCodeAt(j) <= 90){
temp = String.fromCharCode( arr[i].charCodeAt(j) - 13);
newArr.push(temp);
}
else if(arr[i].charCodeAt(j) < 78 && arr[i].charCodeAt(j) >= 65){
temp = String.fromCharCode( arr[i].charCodeAt(j) + 13);
newArr.push(temp);
}
else{
temp = String.fromCharCode( arr[i].charCodeAt(j));
newArr.push(temp);
}
}
newArr.push(" ");
}
var newStr = newArr.join("");
return newStr;
}
rot13("SERR PBQR PNZC");
rot13("SERR CVMMN!");
I don’t understand why is this code is not passing me to the next chalenge. It’s working. It returns a decoded string. Can anyone please explain me what’s wrong?