Do while
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <script type="text/javascript">
- // Dowhile
- //print number 20 to 40
- var a = 20;
- do // the body of the loop is excuted at least once time.
- {
- document.write("the value of a is: "+a+"<br>"); // document.write() use for print line.
- a++; //(a=20 <= 40) the condition is True; therefore execute conditional code.
- }while(a <= 40) //the condition is true; then control jumps to back 'do', and the loop again ececutes unitl then condition is false.
- </script>
- </body>
- </html>
//Execute
//Output
/*
the value of a is: 20
the value of a is: 21
the value of a is: 22
the value of a is: 23
the value of a is: 24
the value of a is: 25
the value of a is: 26
the value of a is: 27
the value of a is: 28
the value of a is: 29
the value of a is: 30
the value of a is: 31
the value of a is: 32
the value of a is: 33
the value of a is: 34
the value of a is: 35
the value of a is: 36
the value of a is: 37
the value of a is: 38
the value of a is: 39
the value of a is: 40
*/
//ThE ProFessoR