In plain words
These three methods work through a list: map turns each item into something new, filter keeps the ones that pass a test, and reduce combines them into one value.
Where you see it
Almost every list on screen in a React app goes through .map(): Chirp's feed takes posts and maps each one to a card. A "show only my posts" toggle is a filter, and a cart total is often a reduce.
What goes wrong
- Curly braces with no return
With braces, an arrow function needs the word return. Without it, map builds a list of undefined.
items.map((item) => { item.name }) - Leaving out reduce's starting value
Without the 0 at the end, reduce starts from the first item itself. On an empty cart it throws "Reduce of empty array with no initial value".
- No key on list items
When map builds a list of components, each needs a stable key such as post.id. Without one, React warns in the console and can mix up which row is which.
What to tell your agent
Quick check
Sign in to earn +10 XP for itChirp's feed shows nothing, but the console logs 20 posts. The code is posts.map((post) => { <PostCard post={post} /> }). What's wrong?