* fix(curriculum): tests quotes * fix(curriculum): fill seed-teardown * fix(curriculum): fix tests and remove unneeded seed-teardown
		
			
				
	
	
	
		
			2.4 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.4 KiB
		
	
	
	
	
	
	
	
id, title, challengeType, guideUrl
| id | title | challengeType | guideUrl | 
|---|---|---|---|
| 56533eb9ac21ba0edf2244cc | Accessing Nested Objects | 1 | https://www.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json | 
Description
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"
Instructions
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.
Tests
tests:
  - text: <code>gloveBoxContents</code> should equal "maps"
    testString: assert(gloveBoxContents === "maps", '<code>gloveBoxContents</code> should equal "maps"');
  - text: Use dot and bracket notation to access <code>myStorage</code>
    testString: assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(code), 'Use dot and bracket notation to access <code>myStorage</code>');
Challenge Seed
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};
var gloveBoxContents = undefined; // Change this line
After Test
(function(x) { 
  if(typeof x != 'undefined') { 
    return "gloveBoxContents = " + x;
  }
  return "gloveBoxContents is undefined";
})(gloveBoxContents);
Solution
var myStorage = {
  "car":{
    "inside":{
      "glove box":"maps",
      "passenger seat":"crumbs"
    },
    "outside":{
      "trunk":"jack"
    }
  }
};
var gloveBoxContents = myStorage.car.inside["glove box"];