Order Total
JavaScript
20 pts
Order Total
The café menu is a Map of item → price.
- Add
"cake"with price 25 usingset(). - Write
orderTotal(order):orderis an array of item names; return the sum of their prices frommenu. Items that are not on the menu count as 0 (check withhas()).
Expected output:
Map(4) { "tea" => 15, "coffee" => 20, "bread" => 10, "cake" => 25 }
40
55
15
Checklist
- Add cake (25 Nakfa) to the menu.
orderTotal(order)returns the sum of the prices.- Items that are not on the menu count as 0.
- Use
get()andhas()on the Map. - Print the menu and the three totals.
🔑 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.
