Last active
October 13, 2021 20:40
-
-
Save RahimGuerfi/95e4ee2408c0c343c802bc308149dcfc to your computer and use it in GitHub Desktop.
Codecademy - Team Stats Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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