Javascript tutorial - 23 - Loop Control - Break And Continue
Dave Partner

Javascript tutorial - 23 - Loop Control - Break And Continue

  • 0 Replies
  • 337 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Dave Partner

  • Administrator
  • Full Member
  • *****
  • 116
    • View Profile
Javascript tutorial - 23 - Loop Control - Break And Continue
« on: January 02, 2017, 04:32:07 AM »
&index=22
<html>
   <head>
      <title></title>
   </head>
   <body>
      <script type="text/javascript" >
         /*
      LOOP CONTROL
      break and continue
      */
       
       //Break
       
       for(var x = 0; x < 20; x++){
         
          document.write(x + "<br/>");
         
          if(x == 12){
             break; //exit loop completely
          }
       }
       
       
       //continue
       for(var x = 0; x < 20; x++){
         
          if(x == 13){
             continue; //exit loop completely
          }
         
          document.write(x + "<br/>");
         
         
       }
     
       
       
       
               
      </script>
   </body>
</html>
« Last Edit: January 02, 2017, 04:51:48 AM by Dave Partner »