Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 22, 2023 06:20
Show Gist options
  • Save codecademydev/a5d4e3279b506abc1fe5b0cc677a31e5 to your computer and use it in GitHub Desktop.
Save codecademydev/a5d4e3279b506abc1fe5b0cc677a31e5 to your computer and use it in GitHub Desktop.
Codecademy export
const team = {
_players :[
{firstName:'samir',lastName:'awad',age:34},
{firstName:'shrief',lastName:'awad',age:33},
{firstName:'loubna',lastName:'awad',age:37}
],
_games :[
{opponent:'paul',teamPoints:2,opponentPoints:2},
{opponent:'rayan',teamPoints:2,opponentPoints:2},
{opponent:'jack',teamPoints:2,opponentPoints:2}
],
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,newTeamPoint,newOpponentPoints){
let game = {
opponent:newOpponent,
teamPoint:newTeamPoint,
opponentPoints:newOpponentPoints
}
this._games.push(game)
}
};
team.addGame('Titans',100,98)
console.log(team.games);
team.addPlayer('Bugs','Bunny',76)
console.log(team.players);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment