Task Using dot and bracket notation, set the variable secondTree
to the second item in the trees
list from the myPlants
object.
Why cant I use [bracket][bracket] notation here (besides the challenge saying to use [bracket].dot notation)?
I thought [bracket][bracket] notation was valid but my log is returning undefined here…
const myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
const secondTree = myPlants[1][1];
console.log(secondTree);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0
Challenge: Basic JavaScript - Accessing Nested Arrays
Link to the challenge: