

Typed Inventory
The Item interface is written for you. Write restockReport(items, threshold) that returns a Report:
low: names of items whose quantity is below the threshold, sorted alphabeticallyvalue: the total value of all stock (quantity times price), rounded to 2 decimal places
Keep the types: the function must accept Item[] and a number, and return Report.
Build it step by step
- Use
filterto keep items withqty < threshold, thenmapto their names. - Sort the names with
.sort(). - Add up
qty * pricewithreduce. - Round with
Math.round(total * 100) / 100.
Examples
restockReport([{ name: "rope", qty: 2, price: 4.5 }, { name: "lamp", qty: 10, price: 12 }, { name: "map", qty: 1, price: 3.25 }], 5)
→ { low: ["map", "rope"], value: 132.25 }
restockReport([], 3)
→ { low: [], value: 0 }
project.ts
TYPESCRIPT
Saved as you type
Tests
0 of 3 passing- •two items running lowrestockReport([{ name: "rope", qty: 2, price: 4.5 }, { name: "lamp", qty: 10, price: 12 }, { name: "map", qty: 1, price: 3.25 }], 5)expected { low: ["map", "rope"], value: 132.25 }
- •empty shelfrestockReport([], 3)expected { low: [], value: 0 }
- •prices that need roundingrestockReport([{ name: "gum", qty: 3, price: 0.1 }], 1)expected { low: [], value: 0.3 }
On the line
+220 XP
Pass all 3 tests to claim it.
