Modify an Object Nested Within an Object

Tell us what’s happening:

Hi, I tried to solve the challenge with a couple of different approaches but I can’t understand why I still can’t resolve the last bit, “The online property is set using dot or bracket notation”.

Any hint? Thanks!

Your code so far

let userActivity = {
  id: 23894201352,
  date: 'January 1, 2017',
  data: {
    totalUsers: 51,
    online: 45

// change code below this line
userActivity[ "data" ].online = 45; // 1st attempt[ "online" ] = 45; //2nd attempt

// change code above this line


//[ "inside" ].glove

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:

Both of those should work. Not quite sure what it’s looking for - try, that’s also valid (and would be the one you’d use in practice as there’s no need for bracket syntax here). Sorry, on phone so can’t test

Thanks for the help.
I reset the page and pasted the solutions again, this time worked. The page just got stuck somehow.
All good.

1 Like

we can also use:
// change code below this line
// change code above this line

// change code below this line;
// change code above this line

Hi there. I was wondering why userActivity[2][1] does not work. Can anybody please clarify?