Filter() provides a new array depending on certain criteria. Unlike map(), it can alter the size of the new array

PHOTO EMBED

Mon Aug 15 2022 20:13:38 GMT+0000 (Coordinated Universal Time)

Saved by @EMR4HKLMN #javascript

// for young people
const youngPeople = users.filter((person) => {
  return person.age <= 15;
});

//for senior people
const seniorPeople = users.filter((person) => person.age >= 50);

console.log(seniorPeople);
console.log(youngPeople); 
content_copyCOPY

https://www.freecodecamp.org/news/top-javascript-concepts-to-know-before-learning-react/