The ride demo produced one total. The parcel desk needs a count and a weight total, so you will build the summary in small steps before formatting it.
Filter for status === "delivered", then map weightGrams to kilograms by dividing by 1000. Reduce those kilograms from 0. Keep the input records unchanged. After those helpers work, connect them in summaryFor and return { count, totalKg }; the braces create an object with two named results.
This unrelated activity report composes the same filter → map → reduce pattern:
const readings = [{ active: true, minutes: 20 }, { active: false, minutes: 40 }];
const minutes = readings.filter(item => item.active)
.map(item => item.minutes)
.reduce((total, value) => total + value, 0);
console.log(minutes);
Edit script.js, then use Run to inspect the supplied checkpoints. Use Submit to check your tasks in order. Keep the supplied probes; change only the requested definitions and final logs.
filter in deliveredOnly(deliveries) to return only delivered records without changing the input.map in weightsInKg(deliveries) to return their weights in kilograms.reduce in sumWeights(weights) to total the numbers, starting from 0.summaryFor(deliveries) to return { count, totalKg }, with zeros for empty input.Delivered COUNT parcels weighing WEIGHT kg from formatSummary(summary), inserting its count and totalKg.formatSummary(summaryFor(deliveries)) on its own line.You can now compose callbacks and array transformations into reports. Take the section quiz to review the patterns.
Filter for delivered records; map each weightGrams to kilograms by dividing by 1000.
Reduce from 0 so there is a numeric total even when nothing was delivered.