We want to create and extract information about your favorite sports team. Basketball, soccer, tennis, or water polo, you pick it. It’s your job to create data using the JavaScript data structures at your disposal: arrays, objects, etc.
Once created, you can manipulate these data structures as well as gain insights from them. For example, you might want to get the total number of games your team has played, or the average score of all of their games.
우리는 당신이 좋아하는 스포츠팀에 대한 정보를 만들고 추출하고 싶다.
농구 축구, 테니스 또는 수구 중에서 하나를 선택해라.
자바스크립트의 데이터 구조를 활용해서 데이터를 만드는 것이 당신이 해야할 일이다.
일단 생성되면, 이러한 데이터 구조를 조작하고, 그것들로부터 통찰력을 얻을 수 있어야 한다.
예를 들어, 팀이 수행한 총 게임의 수 또는 모든 게임의 평균 점수를 얻으려고 할 수 있다.
const team = {
_players : [
{
firstName : 'Pablo',
lastName : 'Sanchez',
age : 14
}
],
_games : [
{
opponent : 'Bronos',
teamPoints : 42,
opponentPoints : 27
}
],
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(opp_n,team_p,opp_p){
let game = {
opponent_name : opp_n,
team_point : team_p,
opponent_point : opp_p
};
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('Titans',100,98);
team.addGame('Red Socks',90,93);
team.addGame('New Agele',89,78);
console.log(team._games);
(결과값)
[ { firstName: 'Pablo', lastName: 'Sanchez', age: 14 },
{ firstName: 'Steph', lastName: 'Curry', age: 28 },
{ firstName: 'Lisa', lastName: 'Leslie', age: 44 },
{ firstName: 'Bugs', lastName: 'Bunny', age: 76 } ]
[ { opponent: 'Bronos', teamPoints: 42, opponentPoints: 27 },
{ opponent_name: 'Titans', team_point: 100, opponent_point: 98 },
{ opponent_name: 'Red Socks',
team_point: 90,
opponent_point: 93 },
{ opponent_name: 'New Agele',
team_point: 89,
opponent_point: 78 } ]