我在窗口中沒有得到結果。我不能找到問題 結果必須從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