Accessing Nested Objects2

My code so far

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
}; // Only change code below this line
myStorage.car.inside["glove box"]; // Change this line

For some reason it isn’t working. Can someone help me please?

1 Like

The original code had var gloveBoxContents = ""; and your code below the “Only change code below this line” should be set to that variable they have.

you need to give it something to return the

myStorage.car.inside["glove box"]; //

like setting a div, and put the contents in
like:

<p id="demo"></p>
<!-- and in the <script> : --->
<script>
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
}; // Only change code below this line
document.getElementById("demo").innerHTML =myStorage.car.inside["glove box"]; // Change this line
</script>


1 Like

Thank you. That worked.