Array Iteration

πŸ‘¨β€πŸ’Ό You've mastered manual array iteration!
πŸ¦‰ This imperative approach works, but it requires mutation (building up an array with push()) and is verbose. In the Array Methods exercise, you'll learn filter() and other functional methods that express the same logic more declaratively:
// Functional approach - one line, no mutation
const inStockProducts = products.filter((p) => p.inStock)
const expensiveCount = products.filter((p) => p.price > 50).length
Understanding the manual approach helps you appreciateβ€”and debugβ€”the functional methods. Both approaches work; the functional style is often clearer for data transformation.

Please set the playground first

Loading "Array Iteration"
Loading "Array Iteration"