Collect items that match a condition:
let numbers = [1, 2, 3, 4, 5, 6]
let evens = []
for (let num of numbers) {
if (num % 2 === 0) {
evens.push(num)
}
}
console.log(evens) // [2, 4, 6]
Start with an empty array. Push items that match your criteria. Later you'll learn array methods like filter() that do this more concisely.