Let us say I have two arrays like the following:
const arr1 = [
{id:1, value:25},
{id:2, value:15},
{id:3, value:35}
];
const arr2 = [
{id:3, value:95},
{id:4, value:65}
];
And I want a third array that includes the 3 items with unique id's, but for the two objects with repeating id's (id:3) - I want to keep the same ID and add the values. Ending up with something like...
const arr3 = [
{id:1, value:25},
{id:2, value:15},
{id:3, value:130},
{id:4, value:65},
];
So I need the most efficient way to find the objects with the same ID's, then do some logic to merge their values and add the merged object back to the new, combined, array.