1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 10 //求和演示 11 var sumWhile = 0; 12 var i=1; 13 while(i<=100){ 14 sumWhile += i; 15 i++; 16 } 17 console.log(sumWhile); 18 19 20 var j = 1; 21 var sumDoWhile = 0; 22 do{ 23 sumDoWhile += j; 24 j++; 25 }while(j<0); 26 27 console.log(sumDoWhile); 28 </script> 29 </body> 30 </html>