1.9 KiB
1.9 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244cd | Accessing Nested Arrays | 1 | 访问嵌套数组 |
Description
var ourPets = [
{
animalType:“猫”,
名称:[
“Meowzer”
“蓬松”,
“洁猫”
]
},
{
动物类型:“狗”,
名称:[
“点”,
“库巴”
“羊羊”
]
}
]。
ourPets [0] .names [1]; //“蓬松”
ourPets [1] .names [0]; //“Spot”
Instructions
myPlants
检索第二个树。 Tests
tests:
- text: <code>secondTree</code>应该等于“松树”
testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
- text: 使用点和括号表示法访问<code>myPlants</code>
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'
Challenge Seed
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = ""; // Change this line
After Test
console.info('after the test');
Solution
// solution required