添加一个打印所有小写字符的 for 语句循环:
var sOne = ''; // scratch variable
// for statements
console.log("\n..for..\n");
for ( i = 65; i <= 90 ; i += 1) {
sOne += String.fromCharCode(i);
};
console.log("sOne is: ", sOne);
输出 -
sOne 是:ABCDEFGHIJKLMNOPQRSTUVWXYZ
这可能非常基本,但如果您能在非常补救的水平上解释它,那就太好了。
最佳答案
小写字母的ASCII码从97-122开始。因此,如果您将 i 值范围设置为 97 到 122,它将打印所有小写字母。事情大概是这样的。
var sOne = ''; // scratch variable
// for statements
console.log("\n..for..\n");
for ( i = 97; i <= 122 ; i += 1) {
sOne += String.fromCharCode(i);
};
console.log("sOne is: ", sOne);
关于javascript - for语句循环小写输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36288706/