Label and continue :- genius student


  • The continue statement breaks one iteration (in the loop) if a specified condition occurs, and continues with the next iteration in the loop.
  • The continue statement can also be used with a label reference

  • Code:-

    <!DOCTYPE html>
    <html>

    <head>
     <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>

    <body>

     <input type="button" onclick="fun_cnt()" value="Test label and continue">

     <script>
      function fun_label()
      {

       var a, b;

       label1:
        for (a = 0; a < 3; a++)
        { //The first for statement is labeled "label1"
         loop2: for (b = 0; b < 3; b++)
         { //The second for statement is labeled "label2"
          if (a === 1 && b === 1)
          {
           continue label1;
          }
          alert("a = " + a + ", b = " + b);
         }
        }

      }
     </script>

    </body>

    </html>
    Label and continue :- genius student Label and continue :- genius student Reviewed by Network security on October 27, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.