Skip to content

Instantly share code, notes, and snippets.

@RahimGuerfi
Last active October 13, 2021 20:40
Show Gist options
  • Save RahimGuerfi/95e4ee2408c0c343c802bc308149dcfc to your computer and use it in GitHub Desktop.
Save RahimGuerfi/95e4ee2408c0c343c802bc308149dcfc to your computer and use it in GitHub Desktop.
Codecademy - Team Stats Project
const team = {
_players: [{
firstName: 'Pablo',
lastName: 'Sanchez',
age: 11
},
{
firstName: 'Emilio',
lastName: 'Rodriguez',
age: 12
},
{
firstName: 'Mehrez',
lastName: 'Ozil',
age: 14
}
],
get players() {
return this._players;
},
addPlayer(firstName, lastName, age) {
const player = {
firstName,
lastName,
age
};
this._players.push(player);
},
_games: [{
opponent: 'Broncos',
teamPoints: 42,
opponentPoints: 27
},
{
opponent: 'LA',
teamPoints: 30,
opponentPoints: 45
},
{
opponent: 'Miami',
teamPoints: 30,
opponentPoints: 10
},
],
get games() {
return this._games;
},
addGame(opponent, teamPoints, opponentPoints) {
const game = {
opponent,
teamPoints,
opponentPoints
};
this._games.push(game);
},
};
team.addPlayer('Steph', 'Curry', 28);
team.addPlayer('Lisa', 'Leslie', 44);
team.addPlayer('Bugs', 'Bunny', 76);
team.addGame('USA', 50, 10);
team.addGame('FR', 25, 30);
team.addGame('IT', 15, 5);
console.log(team.games);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment