Mega Code Archive

 
Categories / JavaScript DHTML / Language Basics
 

Using the while Loop in JavaScript

<html> <head>   <title>Using the while Loop in JavaScript</title> </head> <body>   <script type="text/javascript">   <!--     var i = 0;     var result = 0;     var status = true;         document.write("0");     while(status){       result += ++i;       document.write(" + " + i);       if(i == 10){         status = false;       }     }     document.writeln(" = " + result);     // -->   </script> </body> </html>