Tell us what’s happening:
I don’t understand why ‘top drawer’ is in the brackets in the example, rather than ‘folder 2’ to get the result ‘secrets’.
The format in the challenge appears almost the same: ‘glovebox’ and ‘passenger seat’ would appear to correspond to ‘folder1’ and ‘folder2’, but in the challenge solution ‘glovebox’ is supposed to appear in brackets. This doesn’t make any sense. Either ‘folder2’ should appear in brackets in the example or else ‘inside’ should appear in brackets in the challenge answer. What distinguishes these two situations? What am I missing?
Your code so far
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
var gloveBoxContents = myStorage.car["inside"].glovebox; // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
.
Challenge: Accessing Nested Objects
Link to the challenge: