JavaScript While Loop
The While Loop The while loop loops through a block of code as long as a specified condition is true. Syntax while ( condition ) { // code block to be executed } < !DOCTYPE html > < html > < p id ="demo" > JavaScript While Loop < /p > < script > var txt = "" ; var i=0; while (i < 10 ) { text += "The number is " + i; i++; } document.getElementById( "demo" ).innerHTML = text; < /script > < /body > < /html > The Do/While Loop The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true. Syntax do { // code block to be executed } while ( condition ); < !DOCTYPE html > < html > < p id ="demo" > JavaScript Do/While Loop < /p > < script > var txt = &qu