I'm trying to get only two objects in the resultant array with label one and label two.
How do I filter values in an array of objects. Could anyone please help?
const arr = [{
value: "1",
label: "one"
},
{
value: "2",
label: "two"
},
{
value: "3",
label: "three"
},
];
arr.map((val, index) => val.filter(val.label => val.label === 'one' && val.label === 'two'))
console.log(arr)
I was expecting an output like this below
[{
value: "1",
label: "one"
},
{
value: "2",
label: "two"
},
]