I have the following array of object. I want to get total count where properties are true. i.e in this case total enabled is 5
let data =
[
{
comment: true,
attachment: true,
actionPlan: true
},
{
whenValue: '',
comment: true,
attachment: false,
actionPlan: true
}
]
I tried something below but it didnt worked.
const countObj = questionAttributes.questionMandatoryOptions.reduce((acc, curr) => {
return {
//want to get properties having true values
};
});
For single item in array i can achieve with followign:
const total =
options[0];
const totalelections = Object.values(
total
).filter((v) => v).length;