循环语句 //使用三种语句求0~10的总和
for循环语句
var sum =0;
for(var i = 0;i<10;i++){
sum += i;
}
console.log(sum);
while语句
var i = 0;
var sum=0;
while(i<10){
sum+=i;
i++;
}
console.log(sum);
do while 语句
var i = 0;
var sum=0;
do{
sum+=i;
i++;
}while(i<10);
console.log(sum);
标签:语句,do,sum,dowhile,while,var
From: https://www.cnblogs.com/wslxs/p/17307126.html