Café Delivery
JavaScript
20 pts
Café Delivery
Ruta’s café in Asmara delivers food. Write three arrow functions:
deliveryFee(km)— use a block body withif: up to 5 km costs 20 Nakfa; above 5 km it is 20 plus 4 Nakfa for every km over 5 (8 km → 20 + 3 × 4 = 32).orderTotal(food, km)— one expression: the food price plus the delivery fee (calldeliveryFee).freeDelivery(food)— one expression that returnstruewhen the food costs 200 or more, elsefalse.
Do not use the function keyword. The starter prints:
Fee for 3 km: 20 Fee for 8 km: 32 Total: 152 Free delivery for 250: true
Checklist
- Write
deliveryFee(km)with a block body and the two price rules. - Write
orderTotal(food, km)that usesdeliveryFee. - Write
freeDelivery(food)that returnstrueorfalse. - Use only arrow functions.
- The four lines are printed.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
