DEV Community

Discussion on: Array Methods Used on an Array of Objects

Collapse
 
joelnet profile image
JavaScript Joel

Another cool thing you could do to expand on this would be to break the function out into something reusable like this:

const isOfAge = person => person.age >= 21

guestlist.some(isOfAge)
guestlist.filter(isOfAge)

That way the code becomes more resusable and more readable.

Cheers!

Collapse
 
tallmanlaw profile image
Tisha Tallman

Awesome! Thanks, Joel.