Hi Coders,
I completed this project using if and else if statements. How is this? Any feedback, please?
Thanks
function rot13(str) {
let newStr = '';
for(let i=0; i<str.length; i++){
if(str.charCodeAt(i) < 65){
newStr = newStr + String.fromCharCode(str.charCodeAt(i));
} else {
if(str.charCodeAt(i) + 13 > 90){
newStr = newStr + String.fromCharCode(str.charCodeAt(i) - 13);
} else if(str.charCodeAt(i) + 13 < 90){
newStr = newStr + String.fromCharCode(str.charCodeAt(i) + 13);
} else if(str.charCodeAt(i) + 13 === 90){
newStr = newStr + String.fromCharCode(str.charCodeAt(i) + 13);
}
}
}
return newStr;
}
rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.");