Objects - team-stats

Hello! here is my solution to the team-stats project, let me know what you think on how I can code this better. I had trouble with the previous object oriented project, meal-maker, but after completing this one, Objects, getters, and setters make a bit more sense.

const team = {
  _players:[
    {
      firstName: 'Pablo',
      lastName: 'Sanchez',
      age: 11
    },
    {
      firstName: 'Pete',
      lastName: 'Maravich',
      age:13
    },
    {
      firstName: 'Tim',
      lastName: 'Duncan',
      age: 12
    }
    ],
  _games:[
    {
      opponet: 'Warriors',
      teamPoints: 72,
      opponetPoints: 71
    },
    {
      opponet: 'Kings',
      teamPoints: 69,
      opponetPoints: 84
    },
    {
      opponet: 'Raptors',
      teamPoints: 94,
      opponetPoints: 86
    }
  ],
  get players() {
    return this._players;
  },
  get games() {
    return this._games;
  },
   addPlayer(firstName, lastName, age) {
    let player = {
      firstName: firstName,
      lastName: lastName,
      age: age
    };
    this.players.push(player);
  },
  addGame(opponet, teamPoints, opponetPoints) {
    let game = {
      opponet: opponet,
      teamPoints: teamPoints,
      opponetPoints: opponetPoints
    }
    return this.games.push(game);
  },
};

team.addPlayer('Steph', 'Curry', 28);
team.addPlayer('Lisa','Leslie', 44);
team.addPlayer('Bugs','Bunny', 76);

console.log(team.players);

team.addGame('Heat', 95, 80);
team.addGame('Hornets', 99, 96);
team.addGame('Nets', 91, 87);

console.log(team.games);





Giving feedback for the first time? AWESOME! Check out this video for a boost of confidence: How to Review Someone Else’s Code
Feel free to remove this message before posting.

Cheers!
—Codecademy Community Managers

Looks pretty similar to mine to be fair, the only differences are that your two “add” methods return a new object and mine not, also you are using “this.players” rather than “this._players” and I’m not usre what the difference is!

const team = {
  _players: [{firstName: "Lionel",
             lastName: 'Messi',
             age: 33},
             {firstName: "Gerrard",
              lastName: 'Pique',
              age: 34},
              {fistName: 'Ansu',
              lastName: 'Fati',
              age: 18}],
  _games: [ {opponent: 'Sevilla',
            teamPoints: 3,
            opponentPoints: 0},
            {opponent: 'Osasuna',
            teamPoints: 3,
            opponentPoints: 0},
            {opponent: 'Paris SG',
            teamPoints: 1,
            opponentPoints: 1}],
  get players(){
    return this._players;
  },
  get games() {
    return this._games;
  },

  addPlayer(firstName, lastName, age) {
    let player = {
      firstName: firstName,
      lastName: lastName,
      age: age
    };
    this._players.push(player);
  },

  addGame(opponent, teamPoints, opponentPoints){
    newGame = {
      opponent: opponent,
      teamPoints: teamPoints,
      opponentPoints: opponentPoints
    };
    this._games.push(newGame);
  }

};

team.addPlayer('Steph', 'Curry', 33);
team.addPlayer('Bugs', 'Bunny', 83);
team.addPlayer('Cristiano', 'Ronaldo', 36);

console.log(team._players);

team.addGame('Real Madrid', 3, 0);
console.log(team._games);

Yeah our solutions are very similar, we must have the same thought process when it comes to this type of solution. I have to look back at why i chose to do this.players instead of your this._players, However I am very new to this so I might have done something without noticing it. Thanks for checking out my solution and sharing your own. I hope to see more of your solutions on the forums.