Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created August 8, 2020 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/9830f06a35d0f403920cd40e2e2b1832 to your computer and use it in GitHub Desktop.
Save codecademydev/9830f06a35d0f403920cd40e2e2b1832 to your computer and use it in GitHub Desktop.
Codecademy export
const team = {
_players: [
{
firstName: 'Pablo',
lastName: 'Sanchez',
age: 11
}
],
_games: [
{
opponent: 'Broncos',
teamPoint: 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,
};
return this.players.push(player);
},
addGame(opp, myPts, oppPts) {
const game = {
opponent: opp,
teamPoints: myPts,
opponentPoints: oppPts
};
return this.games.push(game);
}
};
team.addPlayer('Steph', 'Curry', 28);
team.addPlayer('Lisa', 'Leslie', 44);
team.addPlayer('Bugs', 'Bunny', 76);
team.addGame('Titans', 100, 98);
console.log(team.players);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment