StoicBuilder
Later missionMission 4: Twenty dollars on the dotYou can practise it now. It counts once you reach mission 4, after “The total says $011.504.002.99”.Back to HQ

DrillsFree delivery from $20, unless it's $20

Free delivery from $20, unless it's $20

I the LudusQuickBite, built with BoltWarm-upAbout 3 minFree

What happened

QuickBite's menu page says “Free delivery on orders of $20 or more”, and Bolt wrote the checkout rule for it. A customer ordered a green curry and mango sticky rice, $20.00 exactly, and was charged for delivery anyway. Orders of $25 get free delivery as they should.

A customerYour banner says free delivery from $20. My order was $20.00 on the dot and you charged me $2.99. I checked twice.
What you seeOn screen
Subtotal: $20.00 Delivery: $2.99

The MagisterRun it first and read what comes back. Then change the code if you like: your edits go to the review too.

Run it to see what the customer saw. The checks also try a few other order totals.

// QuickBite checkout. The banner says: "Free delivery on orders of $20 or more."
const FREE_DELIVERY_FROM = 20;
const DELIVERY_FEE = 2.99;

const cart = [
  { dish: "Green curry", price: 13.5 },
  { dish: "Mango sticky rice", price: 6.5 },
];

function deliveryFee(subtotal) {
  if (subtotal > FREE_DELIVERY_FROM) {
    return 0;
  }
  return DELIVERY_FEE;
}

const subtotal = cart.reduce((sum, item) => sum + item.price, 0);
const fee = deliveryFee(subtotal);
console.log(`Subtotal: $${subtotal.toFixed(2)}  Delivery: $${fee.toFixed(2)}`);

The code runs in your browser against stand-in data. Nothing is sent anywhere.

Your answer

Reviewed by AI against what a good fix needs. About 10 seconds.

Sign in to get your answer reviewed

It's free. Anything you've typed here stays in this browser and is waiting when you come back.

Sign in with email