JavaScript Loop - Do While loop

Submitted by:Jhon Jhon

Date added:08 March, 2012

Category:JavaScript

A javaScript loop example with Do While loop

Tags: do while loop

Code Snippet:

<html>
<body>

<script type="text/javascript">
i = 0;
do
{
document.write("The number is " + i);
document.write("<br />");
i++;
}
while (i <= 5);
</script>

<p>Explanation:</p>

<p><b>i</b> equal to 0.</p>

<p>The loop will run</p>

<p><b>i</b> will increase by 1 each time the loop runs.</p>

<p>While <b>i</b> is less than , or equal to, 5, the loop will continue to run.</p>


</body>
</html>

 
 

Comments