Basic JavaScript - Accessing Nested Objects

Tell us what’s happening:
Am I getting a bug here?
been trying some answers but still can’t be passed.

Your code so far

const myStorage = {
  "car": {
    "inside": {
      "glovebox": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

const gloveBoxContents = myStorage.car.inside['glovebox']

Your browser information:

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

Challenge: Basic JavaScript - Accessing Nested Objects

Link to the challenge:

Please review the instructions; it appears that the property name has been changed.

Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use dot notation for all properties where possible, otherwise use bracket notation.

Thanks for answering, but I’m still getting error when I use dot notation for all properties. The error is in " gloveBoxContents should be still declared with const", I declared the variable with const but keeps getting error. How to submit bugs to freecodecamp?

const gloveBoxContents = myStorage.car.inside[‘glove box’];

1 Like

The property name should be glove box instead of glovebox.

1 Like

const gloveBoxContents = myStorage.car.inside[‘glove box’];
give him some space

glove… box

The point of the challenge is to teach you that when a property name has spaces you can’t use dot notation and have to use bracket notation.

The point is not for you to change the property name, but to access it as it is in the starting code.

That is also why the example code shown is how it is.


Edit: well I guess technically it was taught in this challenge.

If it has a point it is indicating that it is space

a way of saying

sorry I just wanted to help

Ah I see, I didn’t understand that glovebox needs to have space, thanks a lot

Ah okay, I didn’t understand that glovebox needs to have space, thanks a lot

As @lasjorg said

You changed the property name from the starting code, so you didn’t pass the test.