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 trialNathan Marshall
6,031 Pointsnew 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
231,248 PointsEach 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 "="
Saud Tauqeer
Courses Plus Student 8,099 PointsThanks a lot i wrote the whole program again and it was fixed
Nathan Marshall
6,031 PointsNathan Marshall
6,031 PointsAhh, I see now that makes perfect sense. I should know that. Thanks Steven
Saud Tauqeer
Courses Plus Student 8,099 PointsSaud Tauqeer
Courses Plus Student 8,099 Pointssteven 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
231,248 PointsSteven Parker
231,248 PointsYou'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.