I have an array of objects that looks like this:
[
{1: 22},
{1: 56},
{2: 345},
{3: 23},
{2: 12}
]
I need to make it look like this:
[{1: 78}, {2: 357}, {3: 23}]
Is there a way I could make it so that it can sum up all the values that have the same key? I have tried using a for each loop but that hasn't helped at all. I would really appreciate some help. Thank you!