Use number to control do...while loop in JavaScript

Description

The following code shows how to use number to control do...while loop.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var light = "red";
var counter = 1;<!--from  w  w  w.  j a  v a2s . com-->
do
{
document.write(counter + "<BR>");
counter++;
}
while (counter < 5);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use number to control do...while loop in JavaScript
Home »
  Javascript Tutorial »
    Statement »
      While
Javascript Tutorial While
Check the loop counter for while loop in Ja...
Use Do while loop to reverse a string in Ja...
Use do...while loop and int number to contr...
Use integer variable to control the while l...
Use number to control do...while loop in Ja...
Use while loop to pop all elements in an ar...
Use while loop with an integer to control t...
Use with statement with Math object in Java...