JAVASCRIPT CLIMBSChapter 4 · JS Collections Depth
Map and Filter
JavaScript arrays have built-in helper functions: .map() (creates a new array by transforming each element) and .filter() (creates a new array keeping only elements that match a check).
Worked example
How it reads
- **nums.map(n => n * 2)** loops over elements and returns their doubled values
- nums.filter(n => n % 2 === 0) filters elements returning only those matching the condition

Cloud tip: These methods do not modify the original array; they return a brand new array, helping you keep your data safe.


