re: Map, Filter, Reduce vs For Loops (syntax) VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I was trying to keep it simple for noobs but I think your solution is much cleaner. Typically I will use a mutable accumulator in a reducer. Your ...
 

Then with a mutable accumulator :

const reducer = (filter, map) => (acc, x) =>
  (filter(x) && acc.push(map(x)), acc)

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.

code of conduct - report abuse