Tell us what’s happening:
How can I access the contents of glove box using dot notation and brackets?
Your code so far
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
var gloveBoxContents = myStorage.car.inside. glove box; // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-objects
myStorage.car.inside["glove box"]
if object property name has spaces use brackets.
1 Like
Were you able to resolve it? My code is below but it isn’t correct.
’ ``
// Setup`var myStorage = {
“car”: {
“inside”: {
“glove box”: “maps”,
“passenger seat”: “crumbs”
},
“outside”: {
“trunk”: “jack”
}
}
};
var gloveBoxContents = myStorage.car.inside["glove box"]; // Change this line
Any ideas?
1 Like
myStorage.car.inside["glove box"]`
//if object property name has spaces use brackets
1 Like
myStorage.car.inside["glove box"]`
//if object property name has spaces then you use brackets
1 Like
My code is the same as yours, and the other suggestions on this thread. It doesn’t seem to be working though.
var gloveBoxContents = myStorage.car.inside["glove box"];
ILM
August 7, 2019, 9:38am
7
that code passes for me… what browser are you using? what do the tests say?