DEV Community

Discussion on: ELI5 - "Map-filter-reduce"

Collapse
 
hjfitz profile image
Harry • Edited

You could simplify your JavaScript solution!

const nums = [0,1,2,3,4,5,6,7,8,9];

const ans = nums
  .map(num => num*num)
  .filter(num => num % 2 === 0)
  .reduce((total, num) => total + num, 0);
Collapse
 
isaacleimgruber profile image
IsaacLeimgruber

I definitely prefer chained expressions c: