Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 113 - 2625 PortGPt V2.1
P. 113

    3.  var x = 1;
                                 while (x <= 4)
                                 {
                                    document.write("Value of x:" + x + "<br />");
                                 x++;
                             }

                         4. for (var i = 1; i < 10; i += 2) {

                               if (i === 7) {
                                 break;
                            }
                               document.write('Total: ' + i);
                             }

                         5.  var i = 0;
                             var n = 0;
                             while (i < 5) {
                               i++;
                               if (i === 3) {
                                 continue;
                               }
                               n += i;
                               document.write(n);
                             }

                         6.  var i = 0;
                             for (i=1; i<=5; i++)
                             {
                                document.write(i + "<br/>")
                             }

                         7. var c;
                           document.write("Starting Loop" + "<br />");
                           for(c = 0; c < 10; c++) {
                                document.write("Current Count : " + c );
                                document.write("<br />");
                           }
                           document.write("Loop stopped!");

                         Let's exPLore                                                                 Experiential Learning
                         Surf the Internet and explore more about JavaScript.

                                                                                                   Loops in JavaScript  111

| 108 109 110 111 112 113 114 115 116 117 118 |