I am outputting the correct answer “maps”. however the dot/bracket notation is not accurate. I have looked at the example and can not see the mistake I have made. Any ideas?
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; rv:57.0) Gecko/20100101 Firefox/57.0.
not sure why it works this way. But correct output happens when I add _ to glove box, at the top, as well as bottom. Otherwise it does not work.
The second problem is: var gloveBoxContents = myStorage.car[“inside”].glove_box;
This should be correct as I see it. If you see something worth changing let me know. Maybe its a bug.
The directions say to access glove box not glove_box
These directions specifically tell you not to change above the line. If I had to guess why you aren’t passing the challenge it’s because you didn’t follow the directions. You get the right answer because you are accessing glove_box which now exist because you have changed the initial object you were given.
As you can see your code gets a warning. If you check the warning it’s the biggest clue as to what you’re missing from this challenge.
The point of bracket notation is that it is there to use when you need to reference a variable [myVar] (notice no quotes), or when you need to reference a property that has a blank space in the name such as ['glove box'], notice the quotes that time.
As the warning says it doesn’t really make sense to put inside within brackets, So you get the answer you want because your code is valid JavaScript however you don’t follow the directions about not changing what you aren’t supposed to change.
I would suggest trying to solve it before looking at this but it’s supposed to be implemented like this: