-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjectPractise,js
More file actions
62 lines (61 loc) · 1.13 KB
/
objectPractise,js
File metadata and controls
62 lines (61 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
let team={
_games:[{
opponent: 'peter',
teamPoints: 42,
opponentPoints: 27
},
{
opponent: 'pete',
teamPoints: 43,
opponentPoints: 20
},{
opponent: 'kashish',
teamPoints: 92,
opponentPoints: 26
}],
_players:[{
firstName: 'Pete',
lastName: 'Wheeler',
age: 54
},
{
firstName: 'kashish',
lastName: 'Wheeler',
age: 50
},
{
firstName: 'Peter',
lastName: 'Wheeler',
age: 58
}],
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, myPts, oppPts)
{
let game={
opponent: opp,
teamPoints: myPts,
opponentPoints: oppPts
};
this._games.push(game);
},
};
team.addPlayer('ankit','singh',24)
team.addPlayer('ankita','singh',44)
console.log(team._players)
team.addGame('Titans', 100, 98);
team.addGame('Tilak', 10, 68);
team.addGame('Titys', 70, 88);
console.log(team._games)