Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 19, 2020 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/243976a907948417d480562497522636 to your computer and use it in GitHub Desktop.
Save codecademydev/243976a907948417d480562497522636 to your computer and use it in GitHub Desktop.
Codecademy export
const team = {
_players: [{
firstName: 'Bebeto',
lastName: 'Oliveira ',
age: 20
},
{
firstName: 'Pablo',
lastName: 'Sanchez',
age: 11
},
{
firstName: 'Branco ',
lastName: 'Santos',
age: 30
}],
_games: [{
opponent: 'England',
teamPoints: 3,
opponentPoints: 1
},
{
opponent: 'France ',
teamPoints: 1,
opponentPoints: 1
},
{
opponent: 'Germany',
teamPoints: 0,
opponentPoints: 3
}],
get _playersKeys(){
return Object.keys(this._players[0]);
},
get _gamesKeys(){
return Object.keys(this._games[0]);
},
addPlayer(firstName,lastName,age){
return this._players.push({
firstName,
lastName,
age
})
},
addGame(opponent,teamPoints,opponentPoints){
return this._games.push({
opponent,
teamPoints,
opponentPoints
})
},
}
team.addPlayer('Mohamed', 'Tarek', 34);
team.addPlayer('Feras', 'sheerah', 41);
team.addPlayer('Bugs', 'Bunny', 75);
team.addGame('Egypt', 5, 0);
team.addGame('UAE', 10, 0);
team.addGame('KSA', 15, 0);
console.log(team._games)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment