team stats- add a new array to an object

PHOTO EMBED

Thu Jul 21 2022 21:01:51 GMT+0000 (Coordinated Universal Time)

Saved by @cruz #javascript

const team ={
  _players : [
    {firstName: 'Saqoun', lastName: 'Barkley', age: 26},
    {firstName: 'Evan', lastName: 'Neal', age: 21},
    {firstName: 'Xavier', lastName: 'McKinney', age: 22}
  ],
  _games : [
    {opponent:'Cowboys', teamPoints:30, opponentPoints: 14},
    {opponent:'Eagles', teamPoints:37, opponentPoints: 10},
    {opponent:'Redskins', teamPoints:28, opponentPoints: 7}
  ],

  get players(){
    return this._players;
  },
  get games(){
    return this._games;
  },
  addPlayer(newFirstName, newLastName,newAge){
    let player ={
      firstName:newFirstName,
      lastName: newLastName,
      age: newAge
    };
    this.players.push(player);
  },
  addGame(newOpponent, newTeamPoints,newOpponentPoints){
    let game ={
      opponent:newOpponent,
      teamPoints: newTeamPoints,
      opponentPoints: newOpponentPoints
    };
    this.games.push(game)
  }
};

team.addPlayer('Daniel','Jones','27');

team.addGame('Jets',12,45);

console.log(team._games);
content_copyCOPY

https://www.youtube.com/watch?v=wxk9WKidl48&ab_channel=Codecademy