I have below array of objects. As you can see, there is a nested object named count in each of these objects. I want to get total of Closed, Verify and Analyze
For e.g. the total of Closed is 23, Verify is 3 and Analyze is 20
"byPerson": [
{
"personId": "973567318",
"firstName": "Others",
"lastName": "",
"count": {
"Closed": 7,
"Verify": 3,
"Analyze": 19
}
},
{
"personId": "1514903899",
"firstName": "Yatish",
"lastName": "Patel",
"count": {
"Closed": 16,
"Analyze": 1
}
}
]
I tried this way but it didnt work. for e.g to get total of Closed
cosnt result = data.reduce((a, b) => ({"Closed": a.count["Closed"] + b.count["Closed"]}));