Accessing Nested Objects - JavaScript Help

Accessing Nested Objects - JavaScript Help
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 = "maps"; // Change this line
myStorage.car.inside.['glove box'] = gloveBoxContents;

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.3 Safari/601.7.8.

Link to the challenge:


#2

WORKING:

// 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[“glove box”]; // Change this line