我在窗口中没有得到结果。我不能找到问题 结果必须从charCode创建字符串。String.fromCharCode在运行代码后没有得到结果javaScript
function rot13(str) {
var te = [];
var i = 0;
var a = 0;
var newte = [];
while (i < str.length) {
te[i] = str.charCodeAt(i);
i++;
}
while (a != te.length) {
if (te[a] < 65) {
newte[a] = te[a] + 13;
} else
newte[a] = te[a];
a++;
}
var mystring = String.fromCharCode(newte);
return mystring;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
你对返回的值什么都不做 - 你期望什么? – Li357
'String.fromCharCode(newte);'可能不会做你期望的任何一个 –
你能解释我的想法吗?我尝试了''几种不同的情况,我总是得到错误或没有任何东西 – EdenLT