Page 383 - Webapplication11_C11_Flipbook
P. 383

<BODY>
                    <H3> Using break Statement </H3>

                    <SCRIPT>
                    var i = 0;
                    while (i <= 5)
                    {

                    document.write("Value of i is: " + i +"<BR>");
                    if(i == 3)
                    {
                    document.write("loop break");
                    break;

                    }
                    i++;
                    }

                    </SCRIPT>
                    </BODY>
                    </HTML>
                 On running the above program, we get the following output:















                 2.  To display numbers from 1 to 10 except number 6 by using the continue statement.

                    <HTML>
                    <HEAD>

                    <TITLE> Using continue Statement </TITLE>
                    </HEAD>
                    <BODY>
                    <H3> Using continue Statement</H3>

                    <SCRIPT>
                    var i;
                    for(i=1; i <= 10; i++)
                    {
                    if(i==6)

                    {
                    continue;
                    }
                                                                                                  JavaScript Part 1  381
   378   379   380   381   382   383   384   385   386   387   388