Start with an empty array and add items to the end with .push() to build a list as you go.
About 7 min
Start empty, add as you go
You don't have to know every item up front. Start with an empty array [], then call .push(value) to add an item onto the end. Each push makes the array one item longer:
Building a list one push at a time.
💡Push in a loop
Pushing inside a for loop is a common pattern: it fills an array with a value computed each pass — like list.push(i * 10).
Your turn
Start with an empty array named evens. Use .push() to add the numbers 2, then 4, then 6. The finished array must equal [2, 4, 6].