The while loop

Estimated reading: 1 minute 45 views

A while loop is similar to an if statement, except that its body will keep executing until the condition evaluates to false.

				
					 while ([conditional]) [loopBody]

				
			

Atypical while loop

				
					var i = 0;
 while (i < 100) {
 // This block will be executed 100 times
 console.log(’Currently at ’ + i);
 i++; // increment i
 }
				
			
Share this Doc

The while loop

Or copy link