Hello. I’d be very thankful for any feedback on this project. I got a feeling it could be cleaner and maybe simplier, but not sure how to change it.
Here’s the code:
function rot13(str) {
let decoded = "";
for (let i = 0; i < str.length; i++) {
if (!str[i].match(/[A-Z]/))
{
decoded += str[i];
} else {
if (str.charCodeAt(i) + 13 > 90) {
let over = str.charCodeAt(i) + 13 - 90;
decoded += String.fromCharCode(64 + over);
} else {
decoded += String.fromCharCode(str.charCodeAt(i) + 13);
}
}
}
return decoded;
}
Thank you in advance.