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 trialNathan Marshall
6,031 PointsWhy is undefined showing?
I have given my best shot towards the quiz challenge ( part 1 ) . I am nearly there. I just have one problem.
When I print out the correct and incorrect answers there's an undefined value which gets printed as well? I'm not sure what it is or how to get rid of it.
help would be appreciated.
Thanks
Here is my CodePen link: https://codepen.io/Nathan-Callum-Marshall/pen/zaKaaq?editors=0110
1 Answer
Steven Parker
231,236 PointsI'm not able to replicate your issue either, perhaps you've already fixed it? But you also may have been testing a function in the console, where the return code is always displayed after the function runs. If the function is not designed to return a value, you will always see "undefined" as the last output.
Also, London is not the capital of a city (it is a city). And clouds aren't actually white, but they often appear to be because of the way water droplets scatter light.
Charlie Harcourt
8,046 PointsVery interesting, Steven! So if clouds aren't white then what are they?
:D
Steven Parker
231,236 PointsNot transparent like standing water, the tiny droplets scatter light like little prisms.
Here's a more complete explanation on the Weather Channel website.
Charlie Harcourt
8,046 PointsWell I never knew that! That's very interesting!! :)
Nathan Marshall
6,031 PointsYeah, I managed to fix it :D.In the end, I just sent the questions to two arrays, one for correct answers and one for incorrect. aha apologies for the questions they make no sense my brain was going so fast
Charlie Harcourt
8,046 PointsCharlie Harcourt
8,046 PointsHi
Have you fixed the issue as I am not getting this undefined error?
Further, the first question is a little confusing. 'London is the capital of which city?' as London is a city and the capital of England but not the capital of the United Kingdom as the UK consists of several countries i.e England (Capital London) , Scotland (Capital Glasgow) , northern Ireland (Capital Belfast) and Wales (Capital Cardiff). Also, I wasn't sure what NBA star you were talking about but guessed it would be lebron James :D !!
I am struggling to find the error so maybe try running it again? Having said this the code you have wrote is very good!
:)