SOURCE

/*利用3种循环来计算1+2+3+…+100的值。*/
//while 循环
bht = 0;
i = 1;
while(i<= 100){ 
     bht += i;//在储存数值的变量里面循环储存i的值 
     i++;//每循环一次,自增变量都+1
}
document.write(bht);


document.write("<br />");
document.write("<br />");


//do while循环
bht3 = 0;
i = 1;
do {
     bht3 += i;
     i++;
}
    while(i<=100);
document.write(bht3);


document.write("<br />");
document.write("<br />");


//for循环
bht2 = 0;
    for(i=1;i<=100;i++){
        bht2 += i;
}
document.write(bht2);
console 命令行工具 X clear

                    
>
console