Page 377 - Webapplication11_C11_Flipbook
P. 377

Ð Ðconditional_expression: Similar to for loop, this expression contains a logical condition which evaluates either true
                   or false.
                 Flow Diagram




                                                              do...while Loop Body





                                                          True       Test
                                                                   Condi
on


                                                                       False

                                                                Loop Terminates
                 Example:

                   <HTML>
                   <BODY text="blue">
                   <H2> Using do...while loop </H2>
                   <script>
                   var i = 2;

                   document.write("Loop to display even numbers less than 20 <br><br>");
                   do
                   {
                     document.write(i + "<br><br>");
                     i = i + 2;
                   }while(i<20);
                   </SCRIPT>
                   </BODY>
                   </HTML>
                 On running the above program, we get the following output:



























                                                                                                  JavaScript Part 1  375
   372   373   374   375   376   377   378   379   380   381   382