I am having an array of objects like below
[
{
"id": 27,
"unread_message_count": 0
},
{
"id": 27,
"unread_message_count": 7
}
]
and i use lodash uniqBy to remove the duplicates like below
_.uniqBy(data, 'id')
Which removes the duplicate value like below and returns the result like
{id: 27, "unread_message_count": 0}
Since the second object has some updated value in unread_message_count comparing to first one.I would like to update the unread_message_count as well during the uniq like below
let a = [{id: 27, unread_message_count: 0},{id: 27, unread_message_count: 7}];
_.uniqBy(a, 'id')
Output:
{id: 27, unread_message_count: 7}