Created
August 27, 2019 15:11
-
-
Save debonx/832ab4de07994583e8bf909825cad86a to your computer and use it in GitHub Desktop.
Team JS object for cursed players.
This file contains hidden or 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: 'Carol', | |
| lastName: 'Snitz', | |
| age: 31 | |
| }, | |
| { | |
| firstName: 'Julie', | |
| lastName: 'Lingus', | |
| age: 32 | |
| }, | |
| { | |
| firstName: 'Ziman', | |
| lastName: 'Muddy', | |
| age: 32 | |
| } | |
| ], | |
| _games: [ | |
| { | |
| opponent: 'Wicked', | |
| teamPoints: 95, | |
| opponentPoints: 54 | |
| }, | |
| { | |
| opponent: 'Cheats', | |
| teamPoints: 89, | |
| opponentPoints: 27 | |
| }, | |
| { | |
| opponent: 'Fakes', | |
| teamPoints: 67, | |
| opponentPoints: 65 | |
| } | |
| ], | |
| get players() { | |
| return this._players; | |
| }, | |
| get games() { | |
| return this._games; | |
| }, | |
| addPlayer(firstName, lastName, age) { | |
| const player = { | |
| firstName, | |
| lastName, | |
| age | |
| }; | |
| this._players.push(player); | |
| }, | |
| addGame(opponent, teamPoints, opponentPoints){ | |
| const game = { | |
| opponent, | |
| teamPoints, | |
| opponentPoints | |
| }; | |
| team._games.push(game); | |
| } | |
| } | |
| team.addPlayer('Egon', 'Goatrol', 33); | |
| team.addPlayer('Mitch', 'Dimes', 34); | |
| team.addPlayer('Mark', 'Hopes', 34); | |
| team.addGame('Useless', 12, 75); | |
| team.addGame('Dismal', 26, 54); | |
| team.addGame('Petties', 45, 51); | |
| 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