Can anyone suggest a method to merge objects and calculate the total number of their elements simultaneously? I'm struggling to find a way to combine them while also adding up the chats
count.
Here is an example array:
[
[
{
id: 'call_000001',
date: 2019-04-01T00:00:00.000Z,
chats: 121,
missedChats: 0
},
{
id: 'call_000001',
date: 2019-04-02T00:00:00.000Z,
chats: 92,
missedChats: 1
}
],
[
{
id: 'call_000002',
date: 2019-04-01T00:00:00.000Z,
chats: 13,
missedChats: 0
},
{
id: 'call_000002',
date: 2019-04-02T00:00:00.000Z,
chats: 12,
missedChats: 3
}
],
]
This is the desired result:
[
{
id: 'call_000001',
chats: 213,
missedChats: 1,
},
{
id: 'call_000002',
chats: 25,
missedChats: 3,
},
]
Could someone provide guidance on the most effective approach to achieve this without relying on underscore
or lodash
?