Consider the array below:
[{a:1,b:1},{a:5,b:2},{a:10,b:2},{a:20,b:3}]
Is there a way to create a new array that merges elements with the same b
value, while adding up the corresponding a
values? The desired output should be as follows:
[{a:1,b:1},{a:(5+10),b:2},{a:20,b:3}]