JavaScript flex

const people = [ { name: 'Sara', age: 25, gender: 'f', us: true }, { name: 'Mike', age: 18, gender: 'm', us: false, }, { name: 'Peter', age: 17, gender: 'm', us: false, }, { name: 'Ricky', age: 27, gender: 'm', us: false, }, { name: 'Martha', age: 20, gender: 'f', us: true } ];
// Filter every element of this array let women = people.filter(function(person) { // only return the objects that have the key gender equal to f return person.gender === 'f'; }

To test it

Cool tip: In cases like this you can use console.table instead of console.log to get a table as the output instead of getting the object references.

let women = people.filter((person) => person.gender === 'f');

Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts

Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...

Contact Form

Name

Email *

Message *