Team Stats

Hello
I am stuck with Team Stats projects. The error shows _games[ , syntax : Unexpected Identifier but i checked with videos and it is exactly the same. Could anyone tell me where the problem is pls?
thanks

_players: [ 
    { 
  firstName: 'Maradona',
  lastName: 'Snchez',
  age: 20
    }
]
_games: [ 
   {
     opponent: 'Broncos',
     teamPoints: 42,
     opponentPoints:27
     }
]
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);
},
team.addPlayer('Steph','Curry',28);
team.addPlayer('Lisa','Leslie',44);
team.addPlayer('Bugs','Bunny',76);
console.log(team.players);

Hi there, could you post a link to the project please so we can see the instructions? :slight_smile:

1 Like

Hi @arc2779423039
is this all the code you have?
I see object keys, but I’m missing the object declaration. You add players to an object called ‘team’, which doesn’t exist in the code you posted.

Hello mirija_t

You are right, i cut wrongly and missed object declaration. Now everything is ok as i found out , i miss ’ ,’ between 2 arrays
thanks for your reply

const team = {
_players:[
{
firstName: ‘Maradona’,
lastName: ‘Snchez’,
age: 20},
{
firstName: ‘Paolo’,
lastName: ‘Mateo’,
age:25
},
{
firstName: ‘Marcio’,
lastName: ‘Nunes’,
age:26
}
],
_games:[
{
opponent: ‘Broncos’,
teamPoints: 42,
opponentPoints:27
},
{
opponent: ‘Chelsea’,
teamPoints: 35,
opponentPoints:29
},
{
opponent: ‘Tottemham’,
teamPoints: 40,
opponentPoints:25
}
],
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 (opponentName,points,oppPoints) {
let game = {
opponent: opponentName,
teamPoints: points,
opponentPoints: oppPoints
};
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 (‘Maritimo’, 55, 25);
team.addGame (‘Liverpool’, 45, 35);
team.addGame (‘Fulham’, 27, 30);
console.log(team.games);

1 Like