Imagine you have an array filled with objects:
people = [
{id: "1", name: "abc", gender: "m", age:"15" },
{id: "2", name: "a", gender: "m", age:"25" },
{id: "3", name: "efg", gender: "f", age:"5" },
{id: "4", name: "hjk", gender: "m", age:"35" },
{id: "5", name: "ikly", gender: "m", age:"41" },
{id: "6", name: "ert", gender: "f", age:" 30" },
{id: "7", name: "qwe", gender: "f", age:" 31" },
{id: "8", name: "bdd", gender: "m", age:" 78" },
]
Additionally, you also have an array containing desired ids:
id_filter = [1,4,5,8]
Your task is to filter the people
array to only show the specified ids from id_filter
where the gender is set to m
.