Tell us what’s happening:
When I console.log, it seems that if (str.charCodeAt(index) >= 78) always evaluates to true. Any idea why this is happening?
Your code so far
function rot13(str) { // LBH QVQ VG!
var newstring ="";
for (var index =0; index < str.length; index++){
if (str.charCodeAt(index) >= 78);{
newstring += str.charCodeAt(index) - 13 + ",";
}
}
/*
if (str.charCodeAt(index) < 78){
var difference = 0;
var from13 = 0;
difference = str.charCodeAt(index) - 65;
from13 = 13 - difference;
newstring += 90 - from13 + ",";
}
*/
console.log(newstring);
return str;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
.
Link to the challenge: