1.for循环
var total=0;
for( var i=1;i<=100;i++){
total+=i;
}
console.log(total);
2.while循环
var i=1;
while(i<=100){
total+=i;
i++;
}
console.log(total);
1.for循环
var total=0;
for( var i=1;i<=100;i++){
total+=i;
}
console.log(total);
2.while循环
var i=1;
while(i<=100){
total+=i;
i++;
}
console.log(total);
本文标题:1-100之间的和(for,while(js))
本文链接:https://www.haomeiwen.com/subject/cjwzfxtx.html
网友评论