for语句循环小写输出

for statement loop lowercase output

本文关键字:输出 循环 语句 for      更新时间:2023-09-26

添加一个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);

输出-
唯一的是:EFGHIJKLMNOPQRSTUVWXYZ

这可能真的很基本,但如果你能在一个非常补救的层面上解释它,那就太棒了。

小写字母的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);