Increase and decrease a variable until a number is reached using for and while loop - Javascript Statement

Javascript examples for Statement:while

Description

Increase and decrease a variable until a number is reached using for and while loop

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*  ww w .  ja  va  2 s.c o m*/
for (var i=0;i<100;i++)
{
    document.write("The number is " + i);
    document.write("<br />");
}
while (i>0)
{
    i -= 10;
    document.write("The number is " + i);
    document.write("<br />");
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials