I have an array of objects with the following structure:
var arr = [
{
"value": "abc",
"checked": true
},
{
"value": "xyz",
"checked": false
},
{
"value": "lmn",
"checked": true
}
];
let result = arr.filter(item => item.checked);
console.log(result);
I would want the output to be:
["abc", "lmn"]
Because those two values have checked: true.
I have tried filtering out based on checked value:
let result = arr.filter(item => item.checked);
I am getting the objects that has checked property value that is set to true.
Help would be appreciated.