while Loop In Java Script

This loop continues while the given condition is found true else the loop gets terminated. The variablemeets the condition at the gate of while loop if the variable do not fulfill the condition then the loop will not be executed for even a single time.
While (condition )


code to be executed






<script type=”text/JavaScript”>

var a=0;



document.write(“\t “+a); a++





Understanding program :
value of a is initially 0, the condition with loop is while a is less than 10 the statements typed should be executed. a++ means a=a+1, so the a will get incremented with 1 every time. As soon as a becomes 10 the loop gets terminated.
0 1 2 3 4 5 6 7 8 9
Scroll to Top