I thought I had it with this but realize if the letter is ‘Z’ then it needs to loop around to the starting ascii values of ‘A’.
function rot13(str) {
let shifted = [];
console.log(str.charCodeAt(0))
for (let i=0; i<str.length; i++){
if(str.charCodeAt(i) > 64) {
shifted.push(String.fromCharCode(str.charCodeAt(i) + 13));
}
else {
shifted.push(str[i]);
}
}
shifted = shifted.join("");
console.log(shifted);
return shifted;
}
rot13("SERR PBQR PNZC");