//第一种for循环 var n = 1; var sum = 0; for (; n <= 100; n++){ sum += n; } document.write("for循环:"+'<br/>'); document.write(sum+'<br/>'); //第二种while循环 var n = 1; var sum = 0; while(n<=100){ sum += n; n++; } document.write("while循环:"+'<br/>'); document.write(sum+'<br/>'); //第三种 do while var n = 1; var sum = 0; do{ sum += n; n++; } while (n <= 100); document.write("do while循环:"+'<br/>'); document.write(sum);