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

Stefan Cutajar
Stefan Cutajar
7,747 Points

Unwanted space in list (I guess something wrong with the loop)

Hi, I was trying to complete challenge 2 but got some issues when printing the list it's printing an extra empty list item after each list item. The answers to the questions where all changed to "a" to test the program easily. Any extra info on how can improve the program would be highly appreciated. This is the link to the workspace snapshot ----> https://w.trhou.se/07xty5vta3 Thanks

1 Answer

Steven Parker
Steven Parker
231,269 Points

I think you encountered this same issue in a different file on Sunday, but I'll repeat the answer here:

On line 23 of "quiz.js", instead of an end tag for the list item, there's an extra starting tag:

  htmlInput += "<li>" + item[i] + "<li>";   // original
  htmlInput += "<li>" + item[i] + "</li>";  // fixed

The extra starting tag creates an empty list item after each intended one.

Stefan Cutajar
Stefan Cutajar
7,747 Points

Yes I did Steven I'm really sorry about that I noticed yesterday evening and I tried to delete the post as soon as I noticed but I couldnt find the post.Thanks again for your help

Steven Parker
Steven Parker
231,269 Points

That's OK. You can't delete a question once an answer has been given anyway.