Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJesse Ward
14,882 PointsI don't understand why the answer would be "0"
The question asks "What is the KEY of the fourth element?"
The KEY should be either "May or "April" depending on what you mean by "fourth element." If using the default index, then the answer should be "May" but if it's asking about the fourth KEY name down on the list that's written, then you could say "April".
If the question is supposed to ask what the VALUE of the fourth key is, then I could understand that it is 0, but then the question is worded incorrectly.
1 Answer
Dave StSomeWhere
19,870 PointsIf you do a print_r($myArray), or do a var_dump() you get the 4th one equal to zero. I'm pretty sure that since April didn't define a key value it was assigned the first available numeric value starting with zero:
Array (
[January] => Winter
[February] => Winter
[March] => Spring
[0] => April
[May] => Spring
[June] => Summer
[July] => Summer
[August] => Summer
[September] => Fall
[October] => Fall
[November] => Fall
[December] => Winter )
Jesse Ward
14,882 PointsJesse Ward
14,882 PointsOk interesting thanks for the response.