Accessing nested objects,

Tell us what’s happening:

hi guys, I don’t get the purpose of this challenge, and my other question is that after var is written my Storage which is a object. and at the last is another VAR which after that was written gloveBoxContents. is it an object as well?


Your code so far


// Setup
var myStorage = {
"car": {
  "inside": {
    "glove box": "maps",
    "passenger seat": "crumbs"
   },
  "outside": {
    "trunk": "jack"
  }
}
};

var gloveBoxContents = myStorage.car.inside["glove box"]; // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5.

Challenge: Accessing Nested Objects

Link to the challenge:

if gloveBoxContent has value of an object or not depends on what is being assigned to it, so

do you know what is the value of this?

yes I get this part. my Storage is object and car, inside properties and glove box is value. if i’m not mistaken , but I dont get why its written in that way with var gloveBoxContents .

other than myStorage those are all property names - a property name is used to access a property value. If you follow them you can see which value is being accessed and so what’s the value of gloveBoxContents

1 Like

thanks . yes we reach to maps, what is not clear for me is that the purpose of the challenge.

I have also other question. could u please tell me after VAR( name of obj), we should use = [ or ={

Thank u

to show how to access nested objects

it depends on if you want an array or object

1 Like

ok thank u so much. :slight_smile:

The purpose is to show and practice how to extract a value from an object nexted in another

It’s not about storing the values

But you may need to store the value in a real life senerio hence the gloveBoxContent variable is to store the value extracted

It’s like bring out an ink from a pen

1 Like

thanks for your time and explanation, got it.