Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1001 Bytes

File metadata and controls

37 lines (24 loc) · 1001 Bytes

18. Array transformations

Use map, filter, find, and reduce for clear data flow.

Learn

  • map
  • filter
  • find
  • reduce
  • some
  • every

How it works

map transforms each item, filter keeps matching items, find returns the first match, and reduce accumulates a result. These methods are usually easier to review than a loop that mixes filtering, transformation, and DOM updates. Name callbacks for what they compute.

Common mistake

Forgetting to return from a map callback creates undefined entries.

Guided challenge

Filter completed tasks, map their titles, then calculate a count with reduce.

Run the example

Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.

Completion check

  • Explain the core idea in your own words without reading the code.
  • Change one input and predict the output before running it.
  • Test one boundary or failure case, then record what you changed.