Basic JavaScript - Accessing Nested Objects

Tell us what’s happening:
I tried all the methods, but still compiler shows an error Tell me the solution

Your code so far

const myStorage = {
  "car": {
    "inside": {
      "glovebox": "maps",
      "passenger seat": "crumbs"
    },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Using dot notation
const gloveBoxContents  = myStorage.car.inside.glovebox;

// Using bracket notation
//const gloveBoxContents  = myStorage["car"]["inside"]["glovebox"];

Your browser information:

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

Challenge: Basic JavaScript - Accessing Nested Objects

Link to the challenge:

Use dot notation for all properties where possible, otherwise use bracket notation.

You need to use both dot and bracket notation

You shouldn’t make any changes to this object

Imagine you were telling a robot, who can only follow absolutely specific instructions, to take the item which is in the glove box.

the robot (JS) cannot understand a simple “Get me those maps from the glove box”

you need to tell it “Go to the car, then go inside of the car, then reach for the glove box and take whatever is inside it.”

Moreover Mr. Robot only speaks “robot”. In that language there are no spaces between those words. If it is a single word, the space is being replaced by a dot (.) and if it´s a word/term consisting of multiple words, the language uses brackets [ like this] to indicate that those two words belong together.

so try to tell mr robot that he should get those Maps for you

Hope this helps :slight_smile:

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