Skip to content
Advertisement

Combine objects from an array with the same date into new array of objects using Javascript

I have an array of objects that looks like this:

JavaScript

And I would like to know how to merge the objects in this array by the same date values so that the following array is returned:

JavaScript

My apologies if this is a duplicate question, I just have not been able to find an example where the key & value pairs are different in each object and so I thought I would at least ask.

Advertisement

Answer

Alternatively, you can use a for loop.

Try:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement