Accessing Nested Objects1

Accessing Nested Objects1
0.0 0

#1

Tell us what’s happening:

Your code so far

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = "myStorage.car["inside"].glovebox; // Change this line

Your browser information:

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

Link to the challenge:


#2

There shouldn’t be a " before myStorage.

Then, the inside property is better accessed with dot notation (since it’s made up of letters only).

myStorage.car.inside

Then you access glove box with bracket notation because it has a space in it. You can’t type

myStorage.car.inside.glove box

nor can you omit the space altogether (like you did in your code)