How can I determine the number of active users in a JSON array that includes both active and inactive user statuses?
{
"body": {
"existing_users": [
{
"product": "Pack-2",
"user_status": "Inactive"
},
{
"product": "Pack-1",
"user_status": "Active"
},
{
"product": "Pack-3",
"user_status": "Active"
},
{
"product": "Pack-5",
"user_status": "Active"
},
{
"product": "Pack-1",
"user_status": "Inactive"
},
{
"product": "Pack-1",
"user_status": "Active"
}
]
}
}
The JSON array above contains information on product and user status. I want to specifically calculate the count of active users within this array.
I attempted to use the spread operator:
console.log(...this.user.body.existing_users);
This provided me with a list of all users, but now I need to filter only the active users based on their user status.