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

challenge solution not working:(

https://w.trhou.se/ffybpgkugv

my code is the same as the teacher's but not working. doesnt seem to have created an array. it outputs undefined.

3 Answers

Steven Parker
Steven Parker
231,269 Points

:point_right: Your buildList function is not returning a value.

Inside the function, you construct listHtml, but there's no return statement passing it back to the caller.

Also, when you create a list item in that function, the closing li tag is missing the slash.

 listHtml += "<li>" + arr[i] + "</li>" ;  // <-- note / added

Plus, you might want to add a "You got these questions wrong" header between the two calls to buildList.

That makes sense Steven. I bypassed the buildList function altogether cause it didn't seem to be doing anything. I didn't look to see WHY it wasn't doing anything.

html = "You got " + correctAnswers +  " "  + " question(s) right" ;
html += "<h2>You got these questions right </h2>"
html += right + " " + wrong; //here I added the arrays that you pushed the correct/incorrect answers to


print(html);

thanks it works now. thanks for pointing out the missing statements.