Which fix removes the bug?
const total = items.map((i) => i.price); console.log(total + 1);
- Use
reduceinstead ofmap - Use
filterinstead ofmap - Use
forEachinstead ofmap - Use
flatMapinstead ofmap
map returns an array of prices; a running total needs reduce.
Play Problem Solving ▸