它假设给予“自由的爱”!而是返回“FREE LOVEL”。 其他一些输出是正确的:例如OutPut::(“SERR CVMMN!”)和(“GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK。”
function rot13(str) { // LBH QVQ VG!
var result = [];
var a = str.split(" ");
for (i = 0; i < a.length; i++) {
var b = a[i].split("");
result[i] = b;
}
//return result;
//var result2 = [ ];
for (i = 0; i < result.length; i++) {
for (j = 0; j < result[i].length; j++) {
result[i][j] = result[i][j].charCodeAt() + 13;
if (result[i][j] < 65) {
result[i][j] = result[i][j] - 13; //'?' should revert back to 63***emphasized text*
}
//else if(result[i][j] == )
else if (result[i][j] > 90) {
result[i][j] = result[i][j] - 26;
}
}
}
for (i = 0; i < result.length; i++) {
for (j = 0; j < result[i].length; j++) {
result[i][j] = String.fromCharCode(result[i][j]);
}
}
for (i = 0; i < result.length; i++) {
var d = result[i];
var c = d.join("");
result[i] = c;
}
//return result;
for (i = 0; i < result.length; i++) {
result = result.join(" ");
return result;
}
}
// Change the inputs below to test
console.log(rot13("SERR YBIR?"));
console.log(rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK."))