Home / Code Challenge
Code Practice

Ticket CC-101: the cart that loses money

Your first day at KartKirana, a grocery delivery startup. A ticket lands on your desk: carts with coupons are charging customers the wrong amount. Fix the function, pass the hidden tests, then let a senior AI reviewer read your code like a real pull request.

CareerCracker Team ·20 to 40 min hands-on·July 2026
P
Priya Nair
ENGINEERING MANAGER, KARTKIRANA
TICKET CC-101 · P2

Welcome to the team. Finance says our checkout is quietly losing money: totals come out wrong by a few paise on some carts, one coupon made an order almost free, and last night the cart page crashed for a customer. The function below came from a contractor and it ships today. Fix it.

Acceptance criteria:

  • Totals are correct for any number of items, and an empty cart returns 0
  • couponPercent of 10 means 10 percent off, 100 means free
  • The returned total is rounded to exactly 2 decimals, paise-safe
  • A negative price or quantity throws an Error with message INVALID_ITEM
  • No crashes, ever
0/10

Tests run inside your browser in a sandbox. Nothing you type is stored. AI reviews are limited to 10 per day.