All challenges

TypeScript · easy

Free shipping gate

#17

Situation

Growth wanted "free shipping over $50". What shipped is free shipping under $50. Carts at $12 sail free; carts at $80 get charged. Support is already writing the apology email. Flip the gate.

Objective

Free shipping starts at $50 inclusive (amounts are cents). Just under the threshold must pay shipping; the threshold and above must qualify. qualifiesForFreeShipping(4999)false; qualifiesForFreeShipping(5000)true.

The repo at start

workspace/
└── src/
    └── shipping.ts   (threshold is upside down)

Checks you will turn green

  • exports qualifiesForFreeShipping
  • $49.99 does not qualify
  • $50.00 qualifies

Concepts

control-flowbooleans

Play it in your terminal

With sharpen installed, this command opens exactly this challenge in your local arena:

sharpen 17

First time? The full install is right below.

How to play

  1. 1 Install Claude Code if you do not have it yet: claude.com/claude-code
  2. 2 Install sharpen from npm:
    npm install -g @juanwmedia/sharpen
  3. 3 Then launch it; the arena opens in your browser:
    sharpen 17
  4. or Or try it without installing anything:
    npx @juanwmedia/sharpen 17
  5. 4 And to update when a new version ships:
    sharpen update