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 trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 2 Solution

Uche Onuekwusi
Uche Onuekwusi
17,817 Points

Why did you have to return the listhtml variable,

quiz challenge

1 Answer

Steven Parker
Steven Parker
229,732 Points

I assume you're referring to around time index 2:40, in the "buildList" function. The purpose of that function is to create the list as a string and return it. The code that calls that function uses the returned value to display it on the page.

You'll notice that the function is called more than once, and the outputs are joined together to form a larger string. This is why it makes sense to implement the function to return the constructed string instead of placing it on the page directly.