- 배열, 객체(setter, getter 등)을 활용하여 team stats 만들기
- team 내에 players(firstname, lastname, age) 와 games(opponent, teampoints, opponentpoints) 설정하기
- 선수 3명과 게임 3개 추가하기
const team = {
_players: [{
firstName: 'Marco',
lastName: 'Rossi',
age: 28},
{firstName: 'Ian',
lastName: 'Williams',
age: 34},
{firstName: 'Jamie',
lastName: 'Bowden',
age: 21},
],
_games: [{
opponent: 'Dragon',
teamPoints: 2,
opponentPoints: 3},
{opponent: 'Tiger',
teamPoints: 6,
opponentPoints: 4},
{opponent: 'Zeus',
teamPoints: 0,
opponentPoints: 1},
],
get players() {
return this._players;
},
get games() {
return this._games;
},
addPlayer(firstName, lastName, age) {
let newPlayer = {
firstName,
lastName,
age,
};
this._players.push(newPlayer);
},
addGame(opponent, teamPoints, opponentPoints) {
let newGame = {
opponent,
teamPoints,
opponentPoints,
};
this._games.push(newGame);
}
};
team.addPlayer('Steph', 'Curry', 28);
team.addPlayer('Lisa', 'Leslie', 44);
team.addPlayer('Bugs', 'Bunny', 76);
team.addGame('Titans', 4, 1);
team.addGame('Hurricane', 0, 0);
team.addGame('Killer', 1, 7);
console.log(team.players);
console.log(team.games);