P3.5: JS Advanced Iterators
Iterators are methods used to transform and analyze array lists without writing verbose loops.
Iterators are methods used to transform and analyze array lists without writing verbose loops.
Lesson: p3-5-array-iterators
Iterators are methods used to transform and analyze array lists without writing verbose loops.
map(): Transforms each item in an array, returning a new array.filter(): Returns items that match a condition.reduce(): Compiles the array into a single accumulated result.const numbers = [1, 2, 3, 4];
const doubled = numbers.map(n => n * 2); // [2, 4, 6, 8]
const evens = numbers.filter(n => n % 2 === 0); // [2, 4]