Tell us what’s happening:
I am not getting the required output. Can some one please tell me what is wrong with my code?
Your code so far
function rot13(str) { // LBH QVQ VG!
var reg = /[A-Z]/g ;
var arr=str.split("");
for (var i=0;i<arr.length;i++){
if(reg.test(arr[i])) {
arr[i]=String.fromCharCode((arr[i].charCodeAt(0) % 26) + 65);
}
}
return arr.join('');
}
// Change the inputs below to test
rot13("SERR CVMMN!");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
.
Link to the challenge: