JavaScript From Zero · 25 min · 200 XP
Checkpoint: order summary
Build a fresh summary from an array of order objects without changing the source data.
This checkpoint gives you no function to start from. Before writing any code, sketch the object you're going to return and note what type each part is.
This one brings the data lessons together. The input is an array of orders; the output is one new object holding two arrays, a number and an object of counts. Writing that result down first, with a small example, tells you what to set up before the loop and what to add inside it.
Two rules from earlier apply. Reading data shouldn't change it, so don't sort, splice or edit the orders you're given. And an empty array is a normal input: it should give empty arrays, 0 and an empty object, not an error.
Loading your workspace…