Stack Overflow 75699421 - Add Player to Team
https://stackoverflow.com/questions/75699375/using-the-push-operator-on-a-nested-array-within-an-object/75699421#75699421
by Eric Miller
JavaScript
const team = {
_players: [{firstName: 'Bruno', lastname: 'Guamaries', age: 30},
{firstName: 'Kieran', lastName: 'Trippier', age: 26,},
{firstName: 'Sean', lastName: 'Longstaff', age: 34},],
addPlayer(newFirstName, newLastName, newAge) {
let newPlayer = {
firstName: newFirstName,
lastName: newLastName,
age: newAge};
this._players.push(newPlayer);
}
}
team.addPlayer("walter", "brimley", 69);
team.addPlayer("jonathan", "davis", 88);
console.log("team", team);