let nestedObject = {
id: 28802695164,
date: 'December 31, 2016',
data: {
totalUsers: 99,
online: 80,
onlineStatus: {
active: 67,
away: 13
}
}
};
nestedObject has three unique keys: id, whose value is a number, date whose value is a string, and data, whose value is an object which has yet another object nested within it. While structures can quickly become complex, we can still use the same notations to access the information we need.
userActivity, which includes another object nested within it. You can modify properties on this nested object in the same way you modified properties in the last challenge. Set the value of the online key to 45.
userActivity has id, date and data properties
testString: assert('id' in userActivity && 'date' in userActivity && 'data' in userActivity, 'userActivity has id, date and data properties');
- text: userActivity has a data key set to an object with keys totalUsers and online
testString: assert('totalUsers' in userActivity.data && 'online' in userActivity.data, 'userActivity has a data key set to an object with keys totalUsers and online');
- text: The online property nested in the data key of userActivity should be set to 45
testString: assert(userActivity.data.online === 45, 'The online property nested in the data key of userActivity should be set to 45');
- text: The online property is set using dot or bracket notation
testString: 'assert.strictEqual(code.search(/online: 45/), -1, ''The online property is set using dot or bracket notation'');'
```