BuildlyBuildly
DashboardExercisesProfileHelp

Steps

0 / 7
0 / 165 XP

Zesto: The Fee Engine

From: Priya Nair (City Operations) To: You Subject: Pricing is in a spreadsheet. Help.

Finance found three pricing mistakes this month — all from the fee spreadsheet people keep editing by hand. I want the whole thing as code: one function per rule, each one tested, composed into a single engine.

The rules are below, one step at a time. Build each function, run the checks, and don't move on until the step is green. By the end, orderTotal and riderPayout will be the only two functions anyone at Zesto needs.

One thing I care about a lot: later functions must CALL the earlier ones — if I see the base-fare bands re-typed inside the surge logic, we're back to three copies of the truth, which is how the spreadsheet died.

You'll practice

JS FundamentalsConditionalsArraysObjectsFunctions
Loading kernel…
1

Base fare by distance

20 XP

First rule, straight from the rate card: a delivery up to 2 km costs a flat 25. Beyond that it's 25 + 9 per full km past 2 (partial km don't count — 4.5 km bills like 4 km).

Write baseFare(km).

Priya Nair

Ask Priya Nair

City Operations Lead

Currently on: Step 1. Base fare by distance
Priya Nair

Hey, I'm Priya Nair — City Operations Lead. I'll be working with you on this scenario. Ask me anything — about the data, the brief, the current step, or your code. I won't dump the answer on you, but I'll absolutely point you in the right direction.