Javascript Do While Loop

The Javascript Do While Loop will execute a block of code once, and then it will repeat the loop while a condition is true.


<script type="text/javascript">
   // Code block to be executed.
while (variable<=endvalue);

Note: The <= could be anything that would fit the purpose ex. >, == or whatever.

Javascript Do While Loop Example

<!DOCTYPE html>
<head>  <!-- -->
<title>My first Javascript code</title>   
<body bgcolor="#bnde45">
<legend>Javascript Do While Loop</legend>
<script type="text/javascript">
var j=0;
document.write("<b>The number is " + j + "</b>")
while (j<=10)
<p>The for loop sets <b>i<b> equal to 0.
<p>As long as <b>i</b> is less than or equal to 10, 
the loop will continue to run.
<p><b>i</b> will increase by 1 each time the loop runs.