Team Stats Project

Here is my code for Team Stats Project.

const team = {
  _players: [
    {
      firstName: 'Pete', 
      lastName: 'Wheeler', 
      age: 54
    },
    {
      firstName: 'Paolo', 
      lastName: 'Sanchéz', 
      age: 34
    },
    { firstName: 'Paul', 
      lastName: 'McGuire', 
      age: 31
    }
  ],
  _games: [
    {
      opponent: 'Broncos',
      teamPoints: 42,
      opponentPoints: 27
    },
    {
      opponent: 'Juvenus',
      teamPoints: 42,
      opponentPoints: 13
    },
    {
      opponent: 'Asicos',
      teamPoints: 42,
      opponentPoints: 56
    }
  ],
  get games() {
      return this._games;
  },
  get player() {
      return this._player;
  },
  addPlayer(firstName, lastName, age) {
    let player = {
      firstName: firstName,
      lastName: lastName,
      age: age
    };
  this.players.push(player);
  }
}

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


console.log(team.players);

Not all projects are for sharing, this being one of them.

Oh ok, how can I understand if a project is for sharing ?

If it is in the main curriculum, it is not. Those projects meant for sharing (though why is beyond me) are indicated in their narrative. This is not one of them.

Ok, so I should remove post ? But anyway can I have an help with the error ? Anyway I don’t understand why it doesn’t recognise the push(), it also happened in the previous exercise, I have solved it but I don’t understand what it is due to.

Ah, so there is a question, after all.

There is no getter for players so this would throw an error. Is that what is happening?

1 Like

I formulated the post wrongly, my mistake. :sweat_smile:Thank you for pointing out the error.

1 Like