Beginner
Shipping zones
Write shippingCost(zone): "local" costs 40, "national" costs 80 and "international" costs 250. Any other zone returns null, including tricky names like "constructor" and "toString".
Then write finalShipping(zone, orderTotal): orders of 500 or more ship free (0) to local and national zones; international always pays its normal cost; unknown zones still return null.
Use a switch or a lookup table: your choice.
What Check tests
- Known zones cost 40, 80 and 250
- Unknown zones return
null - Inherited names like
constructoraren't zones - Local and national orders of 500+ ship free
- Smaller orders and international orders pay
- Unknown zones stay
nulleven for big orders
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.