115
rated 0 times
[
120]
[
5]
/ answers: 1 / hits: 5828
/ 4 Years ago, tue, june 23, 2020, 12:00:00
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"
},
]
More From » ecmascript-6