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

Nathan Marshall
Nathan Marshall
6,031 Points

new print function / .innerHTML not working.

I have added the new print function that Dave has stated. For some reason it's not printing out everything that I requested?

Could someone please explain why?

Here's my CodePen Link:

https://codepen.io/Nathan-Callum-Marshall/pen/zaKaaq?editors=1111

Thanks,

2 Answers

Steven Parker
Steven Parker
229,744 Points

Each time you use your "print" function, it replaces the element content, wiping out anything put there before.

You could use a different kind of assignment to add to instead of replace the content each time:

  outputDiv.innerHTML += message;  // notice "+=" instead of "="
Nathan Marshall
Nathan Marshall
6,031 Points

Ahh, I see now that makes perfect sense. I should know that. Thanks Steven

steven can you take a loot at my code too? http://w.trhou.se/7lrvyu2mjb it is not working for some reason. also is it right to follow along the solution and then practice it on your own,i sometimes cant solve the challenges thats why i do it.

Steven Parker
Steven Parker
229,744 Points

You've got a couple of stray quote marks on line 51:

  html+="<h1>"you got these questions correcct "</h1>";

The entire string should be enclosed by just one pair of quotes. Look at line 53 for a correct example.

And for future issues, please always start a fresh question.

Thanks a lot i wrote the whole program again and it was fixed