if we have the objects
const leagues = [
{ id: 1, country: 'England', name: 'Premier League' },
{ id: 2, country: 'Germany', name: 'Bundesliga' },
{ id: 3, country: 'France', name: 'Lige 1' }
]
const teams = [
{ id: 1, country: 'Spain', name: 'Real Madrid C.F.' },
{ id: 2, country: 'Italy', name: 'A.C. Milan' },
{ id: 3, country: 'France', name: 'Olympique Marseille' }
]
And I want to create
const leaguesPeorEquipo = leagues.map((ligas) => ({
name: ligas.name,
country: ligas.country
}));
but instead of name: as Key I would like to put team.name since there is the name of the team I want as Key and then assign the values a name