-
-
Save codecademydev/d20e77829a5f9b2393cb77b1daf98152 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 | |
}, | |
{ | |
firstName: 'Lionel', | |
lastName: 'Messi', | |
age: 16 | |
}, | |
{ | |
firstName: 'Raul', | |
lastName: 'Gomez', | |
age: 14 | |
} | |
], | |
_games: [ | |
{ | |
opponent: 'Barcelona', | |
teamPoints: 3, | |
opponentPoints: 0 | |
}, | |
{ | |
opponent: 'Real Madrid', | |
teamPoints: 2, | |
opponentPoints: 1 | |
}, | |
{ | |
opponent: 'Liverpool', | |
teamPoints: 1, | |
opponentPoints: 1 | |
} | |
], | |
get players(){ | |
return this._players; | |
}, | |
get games(){ | |
return this._games; | |
}, | |
addPlayer(firstName, lastName, age){ | |
let player = { | |
firstName: firstName, | |
lastName: lastName, | |
age: age | |
}; | |
this.players.push(player); | |
}, | |
addGame(opponent, teamPoints, opponentPoints){ | |
let game = { | |
opponent: opponent, | |
teamPoints: teamPoints, | |
opponentPoints: opponentPoints | |
}; | |
this.games.push(game); | |
} | |
} | |
team.addPlayer('Steph', 'Curry', 28); | |
team.addPlayer('Lisa', 'Leslie', 44); | |
team.addPlayer('Bugs', 'Bunny', 76); | |
console.log(team._players); | |
team.addGame('Chelsea', 1, 1); | |
team.addGame('Manchester', 2, 0); | |
team.addGame('London', 0, 4); | |
console.log(team._games); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment