JavaScript do while loop

The JavaScript do while loop iterates the loop while loop, but, the difference is that the loop is executed at least once even when the condition is false.

With a do-while loop the block of code executed once, and then the condition is checked, if the condition is true or false. If it is true then the loop gets executed one more time otherwise gets terminated if the condition evaluates to false.


Syntax
do {
// code to be executed
}
while (condition);


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> JavaScript dowhile Loop Statement </title>
</head>
<body>
<script>
var i=1;
do{
document.write(i + "<br/>");
i++;
} while (i<=5);
</script>
</body>
</html>

Output

JavaScript dowhile Loop Statement




Color Picker

List of color names supported by all browser »



Character Code

List of character codes to display special character »



Language Code

List of all language supported by all browser »



Country Code

List of Country code supported by all browser »