Warning: Undefined array key 1 in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 50

Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 50

Warning: Undefined array key 1 in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 51

Deprecated: urldecode(): Passing null to parameter #1 ($string) of type string is deprecated in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 51

Warning: Undefined array key 1 in /home/wikitechy/public_html/tutorials/node-js/short_url.php on line 56

Warning: Constant HOST already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 7

Warning: Constant BASE_URL already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 8

Warning: Constant BASE_HREF already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 9

Warning: Constant IMG_URL already defined in /home/wikitechy/public_html/tutorials/node-js/config.php on line 10
[100% Working Code] - Node JS While Loop - Node JS tutorial - wikitechy

Node JS While Loop - Node js tutorial



While Loop:

  • While loop is an important in control flow statement.
  • It allows code to be executed based on a Boolean condition.
  • It is equivalent to repeating if condition statement.
  • The expression in while block evaluated first before starting the code execution.
  • If the expression returns true, the block code is executed else not. It is termed as pre-test loop.

Syntax :

while (condition) 
{
  	\\block of code to execute until the condition in the while satisfies
}
 nodejs loop

Learn Nodejs - Nodejs tutorial - nodejs loop - Nodejs examples - Nodejs programs

Read Also

While Loop C

Sample Code :

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

Code Explanation :

 nodejs while loop code

Learn Nodejs - Nodejs tutorial - nodejs while loop code - Nodejs examples - Nodejs programs

  • x is declared as 0.
  • The while part checks the condition as x is not equal to 5 as while (x!=5);
  • The loop block 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)";.

Output :

  • Executing the while loop in the nodejs framework produces the output of the variable x:
 nodejs while loop output

Learn Nodejs - Nodejs tutorial - nodejs while loop output - Nodejs examples - Nodejs programs

Read Also

Python While Loop


Related Searches to Node JS - While Loop - Node JS tutorial