Capstone: A Sales Summary
Combine filter, map, reduce, and object shorthand to turn a raw array of orders into a clean summary — exactly the data-shaping a real dashboard does.
Step 1 of 3
The brief
You're handed a raw array of orders — the kind of data an API returns. Your job is to boil it down into a small summary object a dashboard could display. You'll use the whole modern toolkit at once:
filterthe orders down to the ones that are"paid".reducethose paid orders into a totalrevenue.mapthem to a list ofcustomers.- Assemble a
summaryobject using property shorthand.
This "raw data in, clean summary out" transformation is what a React component does before it renders. Same data work, whether it ends in console.log or in JSX.
Tip
Build it one variable at a time and log as you go. Get paidOrders right first, then compute revenue and customers from it, then bundle them into summary.