Plz help, wha’ts wrong with my code
My results were same with examples.
Plz help!
Your code so far
var newArr = [];
function rot13(str) { // LBH QVQ VG!
var newStr = str.replace(/ /g,"_");
for(var i = 0; i< newStr.length; i++) {
var current = newStr.charCodeAt(i);
var decode;
if(current < 78 && current > 64) {
current = current + 13;
decode = String.fromCharCode(current);
newArr.push(decode);
}
else if(current > 77 && current < 91) {
current = current - 13;
decode = String.fromCharCode(current);
newArr.push(decode);
} else {
current = current;
decode = String.fromCharCode(current);
newArr.push(decode);
}
}
console.log(newArr);
var lastArr = newArr.join('');
var returnArr = lastArr.replace(/_/g, " ");
return returnArr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/caesars-cipher