Compute shipping cost for an order

Node · Node · advanced · greenfield

Adds shipping-cost calculation. Standard shipping is $5 and becomes free at a $50 subtotal; express adds a flat $12 and always applies regardless of the free-shipping threshold. Covered the boundary at exactly $50 and the express-plus-free-standard case.

Requirements

Files touched

--- src/checkout/shipping.js
+function shippingCost(subtotal, express) {
+  let cost = subtotal >= 50 ? 0 : 5;
+  if (express) {
+    cost += 12;
+  }
+  return cost;
+}
+
+module.exports = { shippingCost };

Review this PR

Node practice