Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (10 sloc) 289 Bytes

Iterate with JavaScript While Loops

Another type of JavaScript loop is called a while loop because it runs while something is true, and stops once that something is no longer true.

var ourArray = [];
var i = 0;
while(i < 5) {
  ourArray.push(i);
  i++;
}
Something went wrong with that request. Please try again.