Javascript While Loop

The Javascript while loop statement will execute a block of code when a given condition is true.

Syntax

Note: The <= could be anything that would fit the purpose ex. >, == or whatever.

Javascript While Loop Example

The while loop sets i equal to 0. As long as i is less than or equal to 10, the loop will continue to run. i will increase by 1 each time the loop runs.