Map, Filter, Reduce
JavaScript
10 pts
Map, Filter, Reduce
Use array methods (no for loop) on prices:
cheap— withfilter, the prices below 20.total— withreduce, the sum of all prices.labels— withmap, every price as a string like"12 Nakfa".
Do not change prices. Print the three variables, one per line:
[ 12, 8, 15 ] 100 [ "12 Nakfa", "25 Nakfa", "8 Nakfa", "40 Nakfa", "15 Nakfa" ]
Checklist
- Create
cheapwithfilter. - Create
totalwithreduce. - Create
labelswithmap, without changingpricesor using a loop. - Print the three variables.
🔑 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.
