-
-
Save codecademydev/3a96817bf4c6c64967e4c792a0c508ce to your computer and use it in GitHub Desktop.
Codecademy export
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, | |
} | |
], | |
_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