Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created May 6, 2019 18:13
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/e339a73abbf386cc41e91de95bc4d74d to your computer and use it in GitHub Desktop.
Save codecademydev/e339a73abbf386cc41e91de95bc4d74d to your computer and use it in GitHub Desktop.
Codecademy export
const team = {
_players: [],
_games: [],
get player() {
return this._players;
},
get games() {
return this._games;
},
addPlayer(firstName, lastName, age) {
const playerInfo = {
firstName: firstName,
lastName: lastName,
Age: age,
}
return this._players.push(playerInfo);
},
addGames(opponent, teamPoints, opponenetPoints) {
const gameInfo = {
opponent: opponent,
teamPoints: teamPoints,
opponentPoints: opponenetPoints,
}
return this._games.push(gameInfo);
},
get teamPoints() {
return this._games.teamPoints;
},
};
//add players
team.addPlayer('John', 'Doe', 22);
team.addPlayer('Scotty', 'Walker', 60);
team.addPlayer('Blue', 'Bird', 25);
//add games
team.addGames('Lakers', 54, 36);
team.addGames('Pirates', 100, 99);
team.addGames('Ducks', 1, 2);
//test team object
//console.log(team.player);
//console.log(team.games);
//console.log(team._games)
console.log(team.teamPoints);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment