Skip to main content

//Forloop

For Loop 


  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. </head>
  7. <body>
  8. <script type="text/javascript">
  9. //forloop
  10. //print 10 to 20
  11. var a;

  12. for (var a = 10; a <= 20; a++) // (a=10 is initialization statement);(a<=20 is test condition                                                            statement);(a++ is increment statement)
  13.                          //Initialization:-the control-variable is done first, using assignment                                                  statement such as a=10 or count=0.
  14.                         //Test Condition:- If condition is 'True', the body of loop is ececuted.                                               Otherwise the the loop is terminted.
  15.                        //Increment/Decrement:- here is 'Increment' then, the control variable is                                             incremented and this value again tested.
  16.                       //this process continues till the value of the control variable fails to                                                    satisfy the test-condition.
  17. {
  18. document.write("the value of a is:"+a+"<br>");
  19. }
  20. </script>
  21. </body>
  22. </html>


//Excute


//Output

/*

the value of a is:10

the value of a is:11

the value of a is:12

the value of a is:13

the value of a is:14

the value of a is:15

the value of a is:16

the value of a is:17

the value of a is:18

the value of a is:19

the value of a is:20

*/





                                            //ThE ProFessoR