The number of times specified to execute the same code block in JavaScript or the specified condition is true.
Example
While
How to write a while loop. Use the while loop to run the same code block, and the specified condition is true.
Html>
<body>
<script type= "Text/javascript" >
i=0;
while (i<=5)
{
document.write ("The number is" + i);
document.write ("<br/>");
i++;
Do...while loop syntax.
Do
{
code to is executed
}
while (var<=endvalue);
OK let's look at the instance of while.
< Html>
<body>
<script type= "Text/javascript"
var i=0;
while (i<=10)
{
document.write ("The number is" + i);
document.write ("<br/>");
I=i+1;
}
</script>
</body>
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
Th E number is 6
The number is 7
The number is 8
The number is 9
The number is 10 look again at the Do while instance. <script type= "Text/javascript"
var i=0;
do
{
document.write (' The number is ' + i);
document.write ("<br/>");
I=i+1;
}
while (i<0);
</script>
</body>