I have an array of objects which looks like this:
[
{network: "linkedin", visits: 25}
{network: "twitter", visits: 45}
{network: "linkedin", visits: 26}
{network: "twitter", visits: 27}
{network: "facebook", visits: 235}
{network: "twitter", visits: 744}
]
I want to return a new array that combines the visits where the network is the same, so the result would be:
[
{network: "linkedin", visits: 51}
{network: "twitter", visits: 771}
{network: "facebook", visits: 235}
]
How can I do this in pure JS? My project also has the Lodash library available, which may also offer a solution.
EDIT: The accepted answer in the duplicate question worked for me.