Back to the pile

The total that won't add up

Every line item loads fine. The total comes back as nothing.

nodeSoft~12 min

Fresh from the oven

Clone it down and have a look around.

$git clone https://github.com/loaf-crumbs/total-that-wont-add-up.git

The scenario

A small checkout service backs a cart summary page. It has two endpoints: one returns the line items in a cart, the other returns the cart's total. The page loads the items, lists them, and shows a total at the bottom. The items render perfectly — every name, quantity, and per-line price is correct. But the total at the bottom reads `$NaN`. The same store, the same cart, the same numbers that add up fine line by line refuse to produce a total. Hit the total endpoint directly and you'll see it isn't returning a number at all. There are no errors in the server log, no failed requests, and the items endpoint right next to it works flawlessly against the exact same data. Whatever's wrong, it's specific to how the total comes back.

What done looks like

- The total endpoint returns the cart's total as a plain number - The summary page shows a real dollar amount instead of `$NaN` - The line items list keeps working exactly as before

Stuck?

Peek if you need to — they get more specific as you go.

Taste test

Send it in when you’re ready. We’ll see if it’s tasty.

When you've got the flag, paste it here.

No attempts yet.