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 trialUnsubscribed User
2,211 PointsWhy does the browser display html only if the listHTML variable is returned?
Dave closes his <ol> tag then uses the return statement on the variable: listHTML += '</ol>'; return listHTML;
Unless this happens, the browser doesn't know to print that html when the print function is called. Why?
2 Answers
christopher vaughan
1,411 PointsBasically what's happening is that he's calling a function and then he's displaying whatever that function returns. If the function doesn't return anything, then there's nothing to display. it's like if you put money in a vending machine(call the function) and make a selection (the function runs), but you never reach in and grab the bag of chips(return a value). Obviously you don't have the chips until you reach in and get them :-) (I may be hungry lol)
Unsubscribed User
2,211 PointsThanks. I'm gonna go and return a cookie - to me.