structure is very flexible, which makes this type is very useful. The syntax of the for loop looks like the following: for(initialization; condition; increment/decrement) { Body of the loop; } The for structure within parenthesis there are three parts each separated by semicolon. They are, . The first part of the loop initialize a variable which is also called as control variable.
In most case the control variable is declared as well as initialized. . The second part is the conditional statement that determines how many times the loop will be iterated. .
The third and final part determines how the value of control variable is changed (Incremented/Decremented) Chapter Pages <Html> <Head> <Title> Program - To test for statement in JavaScript </Title> </Head> <Body> <script language="javascript" type="text/javascript"> var no1 = prompt("Please enter Table You want :", " "); document.write("<h2> Multiplication for your need </h2>"); for( var no2= ;no2<= ;no2++) { document.write(no1+" x "+no2+" = "+no1*no2+"<br>"); } </script> </Body> </Html> Illustration . Using for loop Demo Program - To test Pr.. Search... C:\User\ELCOT\Desktop\SCER ^ - X Multiplication for your need x = x = x = x = x = x = x = x = x = x = x = Chapter Pages .
. break and continue statement JavaScript also supports statements used to modify flow control, specifically break and continue . The break statement will terminate the loop early. For example, for(var n= ;n<= ;n++) { if(n== ) { break; } document.write(n+"<br>"); } In the above example, which writes out the value of n starting from , when n is equal to the break statement is executed and the loop is terminated and the output is as follows, Illustration .
Using break statement <Html> <Head> <Title>Demo Program - To test Break command in JavaScript </Title> </Head> <Body> <script language="javascript" type="text/javascript"> document.write("<h2> Using Break Statement </h2>"); for( var