Accessing Nested Objects issue

Accessing Nested Objects issue
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"].glove box; // Change this line

Your browser information:

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

Link to the challenge:


#2
var gloveBoxContents = myStorage.car.inside["glove box"];

You need to use both dot as well as bracket notation.
Whenever you have a variable that has one or more spaces between them, it HAS to be put within quotes using bracket notation.


#4

when you don’t know what’s inside of the nested object

Object.keys(myStorage.car.inside) //keys
Object.values(myStorage.car.inside) //values
Object.entries(myStorage.car.inside) //keys + values