/* while循环 */ var sum=0 var i=1 while(i<=100){ sum+=i; i++; } document.write("sum="+sum) document.write(" <br/>"); /* do-while循环 */ var i=1 var sum=0 do{ sum=sum+i i++ }while(i<=100) document.write("sum="+sum) document.write(" <br/>"); /*for循环 */ var sum=0 for(var i=1;i<=100;i++){ sum+=i; } document.write("sum="+sum+"<br/>")