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 trialAnna Astle
13,614 PointsMy quiz only show the first question wrong/right, but does not display the rest.
I'm working on the quiz.js file. As far as I can tell I followed pretty much the same method as described in the quiz challenge solution. Any help is appreciated!
1 Answer
KRIS NIKOLAISEN
54,972 PointsYou should move the line with the closing </ol> tag and your return statement outside your for loop. The return statement in the loop breaks the execution which is why you only see one line for arrays with data. With an empty array there is no return statement which is why you see undefined.
function buildList(arr){
var listHTML = '<ol>'
for ( var i = 0; i < arr.length; i += 1){
listHTML += '<li>' + arr[i] + '</li>';
}
listHTML += '</ol>';
return listHTML;
}
Anna Astle
13,614 PointsThanks Kris. That makes sense.
Anna Astle
13,614 PointsAnna Astle
13,614 PointsForgot to link my workspace. Here it is:
https://w.trhou.se/druejhdxx5