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 :

do {
} while (condition);
 nodejs dowhile

Learn Nodejs - Nodejs tutorial - nodejs dowhile - Nodejs examples - Nodejs programs

Read Also

Do While Loop in C

Sample Code :

var x=0;
do {
console.log("The value of x is : "+x);
while (x!=5);

Code Explanation :

 nodejs dowhile loop code

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.

 nodejs dowhile loop code output

Learn Nodejs - Nodejs tutorial - nodejs dowhile loop code output - Nodejs examples - Nodejs programs

Related Searches to Node JS Do While Loop - Node JS Tutorial

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.