While Loop
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <script type="text/javascript">
- //while loop
- //print number from 10 to 20
- var a = 10;
- while(a <= 20) //(a=10 <= 20) the condition is True; therefore excute conditional code.
- //when condition is true then excute conditional code; otherwise loop body skipped.
- {
- //the body of loop
- document.write("the value of a is:"+a+"<br>")
- a++; // a++ for this condition 'a <= 20'. value increase upto 20.
- }
- </script>
- </body>
- </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