$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #133

Which fix removes the bug?

const total = items.map((i) => i.price);
console.log(total + 1);
  1. Use reduce instead of map
  2. Use filter instead of map
  3. Use forEach instead of map
  4. Use flatMap instead of map
map returns an array of prices; a running total needs reduce.
Play Problem Solving ▸