45.2 - Taxi Fare Calculator, part 2 — extra complexity (JS lessons — arguments and return)
📘 Task: Taxi Fare Calculator 2.0
This is a continuation of the previous task. The architecture stays the same — the same
4 functions (3 calculators + 1 main).
🧩 Main condition
Only touch the logic inside calculateDistanceCost,
calculateTimeCost and calculateNightSurcharge.
💰 New rates:
- 🚕 Base fee — 20 $ (unchanged)
- 📏 Distance: if the trip is longer than 20 km — rate 4 $/km (discount for long trips),
if 20 km or less — regular rate 6 $/km
- ⏱️ Time: if the trip lasts longer than 30 minutes — rate 0.7 $/min (surcharge for long trips),
if 30 minutes or less — regular rate 0.5 $/min
- 🌙 Night surcharge: if it's night and the amount is greater than 100 $ — +15% (slightly less for large amounts); if it's night and the amount is 100 $ or less — +20%; not night — no surcharge