Dave Partner

Javascript tutorial - 20 - While Loop, Do while and Endless Loops

  • 0 Replies
  • 174 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Dave Partner

  • Administrator
  • Full Member
  • *****
  • 116
    • View Profile
&index=19
<html>
   <head>
      <title></title>
   </head>
   <body>
      <script type="text/javascript" >
         /*
         WHILE LOOP
         while (expression){
               Statement(s) to be executed if expression is true
            }


            DO WHILE LOOP
            do{
               Statement(s) to be executed;
            } while (expression);
         */
       
       var x = 0;
       
      /* while(x < 15){
          x++;
          document.write(x  + ": Hello world <br/>");
       }
       */
       
       do{
         
          document.write(x  + ": Hello world <br/>");
          x++;
       }while( x < 15 )
       
       
       //endless loop
       
       /*
       do{
         
          document.write(x  + ": Hello world <br/>");
          //x++;
       }while( x < 15 )
       */
               
               
      </script>
   </body>
</html>
« Last Edit: January 03, 2017, 01:51:29 PM by Dave Partner »