//利用3种循环来计算1+2+3+…+100的值。
document.write( "------------while循环-------------<br/>");
var sum = 0;
var i = 1;
while(i<= 100){
sum += i;
i++;
}
document.write("1+2+3+...+100 = "+sum+"</br>");
document.write( "------------for循环-------------<br/>");
var sum = 0;
for(var i=1;i<=100;i++){
sum += i;
}
document.write("1+2+3+...+100 = "+sum+"</br>");
document.write( "------------do-while循环-------------<br/>");
var sum = 0;
var i = 1;
do {
sum += i;
i++;
}
while(i<=100);
document.write("1+2+3+...+100 = " + sum);
console