Hi I have an array and I want to filter it as I show below. I checked .reduce() , .filter(), .map() functions and couldn't find proper solution. Can you halp me with that? Thanks.
My array:
var pilots = [
{
id: 2,
name: "Wedge Antilles",
faction: "Rebels",
},
{
id: 8,
name: "Ciena Ree",
faction: "Empire",
},
{
id: 40,
name: "Iden Versio",
faction: "Empire",
},
{
id: 66,
name: "Thane Kyrell",
faction: "Rebels",
}
];
And I want to filter it like:
var pilots = [
{
id: 2
},
{
id: 8
},
{
id: 40
},
{
id: 66
}
];