Accessing Nested Objects

The sub-properties of objects can be accessed by chaining together the dot or bracket notation.

Here is a nested object:

var ourStorage = {
  "desk": {
    "drawer": "stapler"
  "cabinet": {
    "top drawer": { 
      "folder1": "a file",
      "folder2": "secrets"
    "bottom drawer": "soda"
ourStorage.cabinet["top drawer"].folder2;  // "secrets"
ourStorage.desk.drawer; // "stapler"

Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name.

:warning::warning::warning:SPOILER ALERT:warning::warning::warning:

Solution 1:

  1. Initialize variable gloveBoxContent

  2. Get the value of “glove box” under myStorage variable and assign that to gloveBoxContents

     // Only change code below this line
     var gloveBoxContents =["glove box"]; // Change this line

Thanks for writing this. Can you instead update the existing guide here? freeCodeCamp Challenge Guide: Accessing Nested Objects in JSON