Team Stats - Am I allowed to push to the array this way?

So I tried doing this project on my own and using as little information from the instructions as possible. My code runs fine and outputs correctly, but I’m wondering if the methods I wrote to add information to the array should be avoided for any reason? I think I’m using the object property shorthand in my example but I’m still pretty new to all this. :sweat_smile:

In question are the two methods at the end: addPlayer() is the method I wrote, addGame() is the method suggested in the guide.

Link to project

const team = {
  _players: [
    {firstName: 'Filip', lastName: 'Chytil', age: 24},
    {firstName: 'Will', lastName: 'Cuylle', age: 21},
    {firstName: 'Barclay', lastName: 'Goodrow', age: 30},
  _games: [
    {opponent: 'Buffalo', teamPoints: 5, opponentPoints: 1},
    {opponent: 'Columbus', teamPoints: 3, opponentPoints: 5},
    {opponent: 'Arizona', teamPoints: 2, opponentPoints: 1},
  get players (){
    return this._players;
  get games (){
    return this._games;
  addPlayer(firstName, lastName, age) {
    this.players.push({firstName, lastName, age});
  addGame(newOpponent, newTeamPoints, newOpponentPoints){
    let game = {
      opponent: newOpponent,
      teamPoints: newTeamPoints,
      opponentPoints: newOpponentPoints

team.addPlayer('Mika', 'Zibanejad', 30);
team.addPlayer('Vincent', 'Trocheck', 30);
team.addGame('Nashville', 1, 4);
team.addGame('Seattle', 4, 1);

I do notice that my example doesn’t create a local variable whereas the other does? Is there a benefit/downside to this?

Sometimes local variables are written for clarity/readability. I think when it’s obvious enough it’s not necessary. And .push() is a very efficient operation (O(1), constant run time… amortized because of the nature of dynamic arrays) so no issue there.

Awesome, that’s helpful advice. Thanks so much for taking the time to respond! :slightly_smiling_face: