Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 25, 2020 17:04
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/3a96817bf4c6c64967e4c792a0c508ce to your computer and use it in GitHub Desktop.
Save codecademydev/3a96817bf4c6c64967e4c792a0c508ce to your computer and use it in GitHub Desktop.
Codecademy export
const team = {
_players: [
{
firstName: 'Pablo',
lastName: 'Sanchez',
age: 11,
}
],
_games: [
{
opponent: 'Broncos',
teamPoints: 42,
opponentPoints: 27,
}
],
get players() {
return this._players;
},
get games() {
return this._games;
},
addPlayer(firstName, lastName, age) {
let newPlayer = {
firstName: firstName,
lastName: lastName,
age: age,
};
this._players.push(newPlayer);
},
addGame(opponent, teamPoints, opponentPoints) {
let newGame = {
opponent: opponent,
teamPoints: teamPoints,
opponentPoints: opponentPoints,
};
this._games.push(newGame);
},
};
team.addPlayer('Steph', 'Curry', 28);
team.addPlayer('Lisa', 'Leslie', 44);
team.addPlayer('Bugs', 'Bunny', 76);
team.addGame('Kujo', 10, 5);
team.addGame('Gojo', 2, 69);
team.addGame('Alex', 100, 0);
console.log(team._players);
console.log(team._games);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment