The do...while statement will execute a block of code at least once, and then it will repeat the loop while a condition is true.

do
{
code to be executed
}
while (condition)

Let's experiment

Now let's make our own page in Notepad and type in the following:

<html>
<head>
<title>
D0...While statement test
</title>
</head>
<body>
<script type="text/javascript">
   <!--
   var counter = 1;         //initialization of the loop counter

   do {
        document.writeln("<h" + counter + ">This is an h" + counter + " level head</h" + counter + ">");

        ++counter;
        }
// we could try having the color alternate each iteration...
    while (counter <= 6);
   //-->
</script>
</body>
</html>

For

Table of Contents