Page 371 - Webapplication11_C11_Flipbook
P. 371

Flow Diagram


                                             Initialization/Starting
                                                  statement


                                                          Next iteration of the loop






                                                     Test           True         Execute
                                                  Statement                    statement(s)




                                                 False



                                                Exit from loop


                 Example:

                   <HTML>

                   <BODY text="blue">
                   <H2> Using a for loop</H2>
                   <P style="color:red;">
                   <SCRIPT>

                   var p_name=prompt("Enter your name");
                   for (i = 0; i < 5; i++) {
                   document.write("Hello " +p_name+"<BR><BR>"); }

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

























                                                                                                  JavaScript Part 1  369
   366   367   368   369   370   371   372   373   374   375   376