All challenges
Readonly Properties and Arrays
mediuminterfaces100 XPProblem
Define an interface InventoryItem where sku is a readonly string, plus name (string), price (number), and quantity (number). Write totalValue(items: readonly InventoryItem[]): number that returns the sum of price times quantity across all items. The readonly array parameter must guarantee the function cannot push, pop, or reassign elements.
Expected output
13
0Hints
Stuck? Reveal hints one at a time.
Solution
Try solving it yourself first — revealing is always available.
Press Run in the editor — your console output is checked automatically.
No errors
Loading...
Console output appears here. Press Run or just type — the code compiles automatically.