Higher Order Functions: Using Filter, Map and Reduce for More Maintainable Code
Guido Schmitz
3.1K11

Wouldn’t your code just give you the sum of ages over 18? You are mapping a coffee lover property, but not filtering on it.

I think this:

const coffeeLoversAbove18 = people
.filter(ageAbove18)
.map(addCoffeeLoverProperty);

Should be this:

const coffeeLoversAbove18 = people
.filter(ageAbove18)
.map(addCoffeeLoverProperty)
.filter(p => p.coffeeLover);
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.