Use map, filter, find, and reduce for clear data flow.
- map
- filter
- find
- reduce
- some
- every
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.
Forgetting to return from a map callback creates undefined entries.
Filter completed tasks, map their titles, then calculate a count with reduce.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- 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.