Basic JavaScript - Accessing Nested Objects

Tell us what’s happening:
Describe your issue in detail here.
Why does my code not accepted? Though I follow the requirements of test

  **Your code so far**
const myStorage = {
"car": {
  "inside": {
    "glove box": "maps",
    "passenger seat": "crumbs"
   },
  "outside": {
    "trunk": "jack"
  }
}
};

const gloveBoxContents = myStorage.car["inside"]["glove box"];
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77

Challenge: Basic JavaScript - Accessing Nested Objects

Link to the challenge:

The task asks you to “Use dot notation for all properties where possible, otherwise use bracket notation.” hence why your code is not being accepted, since you can do the code below.

const gloveBoxContents = myStorage.car.inside[“glove box”]

Ohh, that’s why it’s not accepted. “For all properties.” But the solution I came up with is accepted if there is no task. Is it right?

Yup, your way would work fine.

Okay, Thank you @Bobby98 !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.