Skip to content

Instantly share code, notes, and snippets.

@pvanschy
Forked from codecademydev/app.js
Created February 9, 2021 03:22
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 pvanschy/31782ce1d56b1f9273b8874ec07baa5a to your computer and use it in GitHub Desktop.
Save pvanschy/31782ce1d56b1f9273b8874ec07baa5a to your computer and use it in GitHub Desktop.
Codecademy export
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