DEV Community

Array Methods Used on an Array of Objects

Tisha Tallman on November 09, 2018

Array methods can be used on an array of objects with relative ease with one nuance – accounting for object properties. The solution is to utilize...
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.