JavaScript do while loop will always be executing at least once, even if condition false, because condition works at the end of block of code so, block of code executed before the condition.
Syntax
TUTORIAL
Syntax
do {
code block to be executed
}
while (condition);
TUTORIAL
<html> <body> <button onclick="phpFunction()">Click Me</button> <p id="result"></p> <script> function phpFunction() { var data = ""; var i = 0; do { data += "<br>The count " + i; i++; } while (i < 10); document.getElementById("result").innerHTML = data; } </script> </body> </html>
OUTPUT
The count 0 The count 1 The count 2 The count 3 The count 4 The count 5 The count 6 The count 7 The count 8 The count 9
What is the use of step statement for loop? and
ReplyDeleteCan we use if statement in while loop?