DEV Community

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

Collapse
 
jbbn profile image
João Bueno

Totally agree Dian :)

Just to register another way to write the same, I would code like this:

const ans = numbers.reduce((total, num) => (
  num % 2 === 0 // replaces filter
    ? total + num * num // replaces map
    : total
))

Regards!