Accessing Nested Objects!

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"]["glove box"];
// 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/63.0.3239.84 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/accessing-nested-objects

1 Like

You’re not wrong in that your line of code will produce the right output.

In the same way var gloveBoxContents = myStorage["car"]["inside"]["glove box"]; would work to give you the right solution but not pass their tests, they are looking for a specific solution with a mixture of dot and bracket notation where you don’t have to use bracket notation unless you have spaces in the object’s key.

i tray to use your way bracket nation and still dose not work

var gloveBoxContents = myStorage.car.inside[“glove box”]; // “maps”

1 Like