function rot13(str) { // LBH QVQ VG!
var newStr = str.split(" ");
for(var i = 0; i < newStr.length; i++){
for(var j = 0; j < newStr[i].length; j++){
if(newStr[i].charCodeAt(j) < 78){
String.fromCharCode(newStr[i].charCodeAt(j) + 13);
}
else if(newStr[i].charCodeAt(j) >= 78){
String.fromCharCode(newStr[i].charCodeAt(j) - 13);
}
}
}
return newStr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
我能够将原始代码翻译为其实际字词,但我无法将它们更改为新字符串上的正确字词来完成。有人可以请帮助。如何用新字符串替换旧字符串的值
调用'使用String.fromCharCode()'没有做什么用的返回值是毫无意义的。 – Pointy
我知道,但我想知道如何处理返回的值,所以我可以得到“免费代码营”的输出 –