function rot13(str) { // LBH QVQ VG!
var newStr = "";
for(var i=0; i<str.length; i++) {
var char = str.charCodeAt(i);
if(char<65 && char>90) {
char = char;
} else if(char < 78) {
char += 13;
} else {
char -= 13;
}
newStr += String.fromCharCode(char);
}
return newStr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
//"FREE-CODE-CAMP" 想得到"FREE CODE CAMP",该如何改动
互换的青春
相关分类