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 add one team to the new array and calculate how many games the team has won. The order doesn’t really matter.

const transformedTeams =({
name:’Liverpool’,
won:2},{
name:’Newcastle’,
won:1},{
name:’Chelsea’,
won:0});
The code I have written looks like this, but unfortunately isn’t returning the correct value:
SEMrush

teams.map(team =>{if(teams.includes(team.name)){return{
name: team.name,
won: team.won ===true?1:0}}})