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 trialAaron Hasbrouck
1,295 PointsNew print method question
Okay I'm not sure if I post the workspace correctly. But, when I use the new elementById method I'm having troubles.
First, I put outside the functions and such after the print(html);. This made the program print the last statement. Then I put it in the functions and it prints them all, but they disappear and show the number of questions correct. What can I do to make it display them all simultaneously. Also, what can I do the make the unordered list work correctly.
1 Answer
Steven Parker
231,269 PointsYour print function replaces the output each time you call it.
It sounds like you want it to add to the output instead. For that, use the concatenating assignment operator:
var outputDiv += document.getElementById('output');
Your unordered list seems to be created by the printList function. I noticed a few issues with it:
- no matter what the argument is, the loop uses the length of correctQuestion
- each time through the loop prints the same (first) item ("
list[0]
") - this function is never called by the program