Link Search Menu Expand Document

Iterate with JavaScript While Loops

Summary

  • Code can be ran multiple times using a loop.
  • The while loop only runs while a specific condition is true.

Final Code

// Setup
var myArray = [];

// Only change code below this line
var i = 5;
while(i >= 0) {
  myArray.push(i);
  i--;
}