Page 105 - DCAP202_Fundamentals of Web Programming
P. 105

Fundamentals of Web Programming




                    Notes          Output
                                   The number is 0
                                   The number is 1
                                   The number is 2

                                   Explanation: The loop will break when i=3.

                                   8.2.5 Continue Statements

                                   The continue statement will break the current loop and continue with the next value.


                                          Example: It is showing an example of continue.
                                   <html>
                                   <body>
                                   <script  type=”text/javascript”>
                                   var  i=0
                                   for  (i=0;i<=10;i++)
                                    {
                                     if  (i==3)
                                    {
                                     continue;
                                    }
                                     document.write(“The  number  is  “  +  i);
                                     document.write(“<br  />”);
                                    }
                                   </script>
                                   </body>
                                   </html>
                                   Output
                                   The number is 0
                                   The number is 1

                                   The number is 2
                                   The number is 4
                                   The number is 5

                                   The number is 6
                                   The number is 7
                                   The number is 8
                                   The number is 9
                                   The number is 10

                                   Explanation: The loop will break the current loop and continue with the next value when i=3.









          98                                LOVELY PROFESSIONAL UNIVERSITY
   100   101   102   103   104   105   106   107   108   109   110