freeCodeCamp Challenge Guide: Iterate with JavaScript While Loops

you can run it like this as well, without using push which adds the item to end of array. Instead you can index it by its value at taht position

// Setup
var myArray = [];

// Only change code below this line.
var i = 0;
while (i<5) {
  myArray[i] = i;
  i++;
}
7 Likes