Combine objects with the same values/id and add sum to new object

I have an array of objects that looks like this:
const teams =[{
name:'Liverpool',
won:true,
opponent:'Man Utd'},{
name:'Liverpool',
won:true,
opponent:'Liverpool'},{
name:'Chelsea',
won:false,
opponent:'Arsenal'},{
name:'Newcastle',
won:true,
opponent:'Liverpool'}];
I want the final array to look like the following. It should only […]

See original post by invalid@example.com (Helen Tashot)

Leave a Reply