Example code doesn't match the code in the problem window --
Example:
var ourPets = {
"cats": [
"Meowzer",...
Problem:
var myPlants = [
{
type: "flowers",
list: [
"rose",...
Changing the problem code to match the example by removing type: and list: (with brackets to match) satisfies the first requirement ("secondTree should equal "pine"") but the second requirement ("Use dot and bracket notation to access myPlants") will not update when what I assume is the correct answer is used: myPlants.trees[1]
If the problem code is left alone and the above answer is entered, this problem occurs: "TypeError: Cannot read property '1' of undefined"
Challenge Accessing Nested Arrays in JSON has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants.trees[1]; // Change this line
Hello billsrambo
One way to solve the problem is: var secondTree = myPlants[1].list[1];
This is because myPlants is an array with 2 items (flowers and trees ,with myPlants[1] indicate the second one= trees ) .
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants[1].list[1]; // Change this line
@llovera is correct. In the future, please ask for help in Help Chat.
Thanks and Happy Coding!
Thanks LLovera. I really had a hard time with this one. And didn't get much help in the Help Chat.
Once I am able to see the solution I am able to put it together and get a real understanding on how it works.
Thanks again.
Array is numbered from"0" not "1".
`// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants[1].list[1]; // Change this line`
This worked for me.
removed solution by mod
2017/3/23 23:01,"Lance" notifications@github.com寫道:
@ar94952 https://github.com/ar94952
Please do not post your solution on here. You could help people at
FreeCodeCamp Chat Room or Forum. GitHub Issues are for reporting bugs on
the website only.Happy Coding!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/freeCodeCamp/freeCodeCamp/issues/6345#issuecomment-288746427,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AZVG63w6xcLwSeajl16Uy0wRrlA1EFNCks5rook-gaJpZM4HIr1Z
.
Hello billsrambo
One way to solve the problem is: var secondTree = myPlants[1].list[1];
This is because myPlants is an array with 2 items (flowers and trees ,with myPlants[1] indicate the second one= trees ) .// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];// Only change code below this line
var secondTree = myPlants[1].list[1]; // Change this line
good job sweet heart :*
Most helpful comment
Hello billsrambo
One way to solve the problem is: var secondTree = myPlants[1].list[1];
This is because myPlants is an array with 2 items (flowers and trees ,with myPlants[1] indicate the second one= trees ) .
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = myPlants[1].list[1]; // Change this line