DEV Community

Discussion on: Map, Filter, Reduce vs For Loops (syntax)

Collapse
 
mesteche profile image
Mesteche

Then with a mutable accumulator :

const reducer = (filter, map) => (acc, x) =>
  (filter(x) && acc.push(map(x)), acc)
Thread Thread
 
joelnet profile image
JavaScript Joel • Edited

Awesome!

I'm a big fan of the comma operator. I decided to leave it out in this code block to not confuse anyone. But I use it pretty regularly in my own codebase.