Shop Stock
JavaScript
10 pts
Shop Stock
The Map stock holds how many of each item the school shop has. Using Map methods:
- Print whether the shop has
"bread"(usehas()). - Add
"bread"with 12 and delete"milk"(it is sold out). - With
forEach, print every pair asitem: amount. - Print the size.
Expected output:
false tea: 10 sugar: 4 bread: 12 3
Checklist
- Check whether the shop has bread.
- Add bread (12) and remove milk.
- Loop over the pairs with
forEach. - Print the check, the pairs and the size.
🔑 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.
