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 trialYifang kuo
Front End Web Development Techdegree Student 12,376 PointsWhy the answer is not Friday
After the code below runs, what value is stored in the variable dayOfWeek: function getDay() { return "Monday"; alert("Calculating day"); return "Friday"; }
var dayOfWeek = getDay();
4 Answers
Nattapol Kamolbal
15,528 PointsAs soon as the function encounters a return statement it exits the function and returns a value.
Joshua Ouma
20,865 PointsBecause the program stopped and exited the function when it encountered the first return statement and then returned its value
chris kinser
2,800 Pointsas far as I know it doesn't return nothing but a "undefined". Hypothetically the first return the second is to through you of and it also doesn't come up as syntax error either.
sheraprincessofwonder
10,182 PointsIt will return "Monday"
xufan liu
1,121 Pointsxufan liu
1,121 Pointsso the second return does not run ? what is the second return for then?