Hey there, I am encountering a problem with filtering out values from an array of objects. Essentially, I have an array of objects
const arr = [
{
"id": null,
"name": null,
"role": "Authorized Redistributor (AR)",
"checked": false,
"checkBoxPatched": true
},
{
"id": null,
"name": null,
"role": "System Of Record (SOR)",
"checked": true,
"checkBoxPatched": true
},
{
"id": null,
"name": null,
"role": "Authorized Redistributor (AR)",
"checked": true,
"checkBoxPatched": true
}
]
arr.map(res => res.checked ? res.role : "").join(', ')
// ", System Of Record (SOR), Authorized Redistributor (AR)"
I am looking to retrieve comma-separated role
values if checked
is true. So based on the above object, the output should be
System Of Record (SOR), Authorized Redistributor (AR)
.