* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
1.8 KiB
1.8 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244cc | Accessing Nested Objects | 1 | 访问嵌套对象 |
Description
var ourStorage = {
“桌子”:{
“抽屉”:“订书机”
},
“内阁”:{
“顶级抽屉”:{
“folder1”:“一个文件”,
“folder2”:“秘密”
},
“底部抽屉”:“苏打水”
}
};
ourStorage.cabinet [“top drawer”]。folder2; //“秘密”
ourStorage.desk.drawer; //“订书机”
Instructions
myStorage
对象并将glove box
属性的内容分配给gloveBoxContents
变量。对于名称中包含空格的属性,请使用括号表示法。 Tests
tests:
- text: <code>gloveBoxContents</code>应该等于“地图”
testString: assert(gloveBoxContents === "maps");
- text: 使用点和括号表示法访问<code>myStorage</code>
testString: assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(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
console.info('after the test');
Solution
// solution required