Aug 29, 2017 · 1 min read
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);