From 612912e14b85d3ca59b02986d9fb0f454aaea475 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 6 Oct 2026 19:48:26 +0000 Subject: [PATCH] feat: count the units in a cart Signed-off-by: Alejandro Mery --- src/cart.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cart.js b/src/cart.js index e3962bc..0e8bb6c 100644 --- a/src/cart.js +++ b/src/cart.js @@ -20,3 +20,8 @@ export function applyDiscount(amount, percent) { } return amount - (amount * percent) / 100; } + +/** Count the units across the given items. */ +export function countUnits(items) { + return items.reduce((units, item) => units + item.quantity, 0); +}