Javascript Do-While

Do while loop is almost similar to the while loop except that the loop statement is executed at least once. In this, the conditional check is written at the end of the loop iteration. So, the statement is executed first before the condition is tested.

Syntax of do while Loop

do{
    Statements;
}
while(condition)

Example

<script>
var i = 0;
do {
    document.write("Number : " + i + "<br/>");
    i++;
} 
while (i < 4); 
</script>

Output





Read more articles


General Knowledge



Learn Popular Language