Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 483 Bytes

Challenge-Accessing-Nested-Objects-In-Json.md

File metadata and controls

22 lines (19 loc) · 483 Bytes

#Challenge: Accessing Nested Objects in JSON

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

Here is a nested JSON 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; // "stap