Node JS Do While Loop - Node JS tutorial
Do While Loop
- The do statement executes a statement or a block of statements repeatedly until a specified expression evaluates to false.
- The body of the loop must be enclosed in braces, {}, if it consists of a single statement.
- It is also called as exit-condition loop.
Syntax :
Learn Nodejs - Nodejs tutorial - nodejs dowhile - Nodejs examples - Nodejs programs
Read Also
Do While Loop in CSample Code :
Code Explanation :
Learn Nodejs - Nodejs tutorial - nodejs dowhile loop code - Nodejs examples - Nodejs programs
- x is declared as 0.
- Do while loop is stated with incrementing x value as x++ and the same is sent for output to console with the line of code “console.log("The value of x is : "+x);".
- Finally the while part checks the condition as x is not equal to 5 as while (x!=5);a block of code for one time and check the condition.
Output :
Executing the do while loop in the nodejs framework produces the output of the variable x.
Learn Nodejs - Nodejs tutorial - nodejs dowhile loop code output - Nodejs examples - Nodejs programs