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 trialNihad Ahmic
1,619 PointsWhen you call noAlert() function for the second time, why the value (5) is not returned again?
Is it something about the RETURN key, that only returns value once. I am confused for seeing the alert box and not seeing the value 5 returned. The case is shown in the end of this video (https://teamtreehouse.com/library/using-multiple-return-statements#questions)
3 Answers
Zimri Leijen
11,835 PointsThat's because he is running it in the console and he has a second function right after it alert()
, the alert function doens't return anything, therefore you see undefined.
Nihad Ahmic
1,619 PointsThanks Zimri Leijen :)
Nikola Lukic
8,061 PointsZimri Leijen wrote:
it is actually called, as you can see by the alert window popping up. You just don't see the return statement because the console ignores it.
I don't really understand why the console ignores the return statement from the noAlert()
function here.
Could someone explain what is happening here or point me in the right direction to learn more about this?
Nihad Ahmic
1,619 PointsNihad Ahmic
1,619 PointsThank you. But why noAlert() function is not called for the 2nd time. It is well defined. Or it has to do sth with the console?
Zimri Leijen
11,835 PointsZimri Leijen
11,835 Pointsit is actually called, as you can see by the alert window popping up. You just don't see the return statement because the console ignores it.