JavaScript While Loop

JavaScript While Loop


JavaScript While Loop
A "While" Loop is used to repeat a specific block of code an unknown number of times, until a condition is met.
The Syntax of while loop is as follows:
Initialization
For (expression) {
Statement(s) to be executed if test condition is true
}
Flowchart of While Loop
JavaScript Loops | Types of Loops - FutureFundamentals
Example - JavaScript program to print numbers from 1 to 10 using while loop:

 
Output