function rot13(str) { // LBH QVQ VG!
var arr = str.split('');
function add13(someStr){
if (someStr.charCodeAt() > 90 || someStr.charCodeAt() < 65) {
return String.fromCharCode(someStr.charCodeAt() + 0);
}
else if ((someStr.charCodeAt() + 13) > 90) {
return String.fromCharCode(someStr.charCodeAt() + 13 - 90 + 64);
} else {
return String.fromCharCode(someStr.charCodeAt() + 13);
}
}
var newArr = arr.map(add13);
var regExp = /-/gi;
return newArr.join('').replace(regExp, " ");
}
// Change the inputs below to test
rot13("SERR CVMMN!");
Any advice on how to make it more readable, concise, clean, etc would be appreciated .