-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14_modifyNestedObject.js
More file actions
43 lines (38 loc) · 913 Bytes
/
14_modifyNestedObject.js
File metadata and controls
43 lines (38 loc) · 913 Bytes
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
// Modify an Object Nested Within an Object
// Consider this object:
let nestedObject = {
id: 2880269164,
date: 'December 31, 2016',
data: {
totalUsers: 99,
online: 80,
onlineStatus: {
active: 67,
away: 13,
busy: 8
}
}
};
// Assign the value 10 to the busy key.
nestedObject.data.onlineStatus.busy = 10;
console.log(nestedObject);
/* Here we've defined an object userActivity, which
includes another object nested with it. Set the value
of the online key to 45. */
let userActivity = {
id: 23894201352,
date: 'January 1, 2017',
data: {
totalUsers: 51,
online: 42
}
};
// Only change code below this line
userActivity.data.online = 45;
// Only change code below this line
console.log(userActivity);
/*
{ id: 23894201352,
date: 'January 1, 2017',
data: { totalUsers: 51, online: 45 } }
*/