Basic JavaScript: Accessing Nested Objects

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};


var gloveBoxContents = myStorage.car.inside["gloveBox"];

my solution is not working

There’s no gloveBox property in inside;

However there’s a glove box one. :wink:

Hope it helps.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums