-
-
Save codecademydev/e339a73abbf386cc41e91de95bc4d74d 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: [], | |
_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