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

So, what's the deal with the undeclared 'html' variable at the bottom of the script?

Dave just kind of starts using this variable to print things with no explanation.

In the previous lessons he had been calling the print function multiple times (which no longer works do to the re-factoring of the print function).

Is building up a single variable to print a best practice? Why do it this way as opposed to another way?

I can't help but think this should have been discussed in detail.

1 Answer

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,075 Points

Don't worry it is nothing confusing, you are just thinking too hard about it. html is just a variable that is holding a string (which will be displayed as html because of the html tags it uses). All he is doing is adding more html and text to the original string then printing it out. Javascript doesn't need to have the word var before a variable name (if its is a variable that wasn't created before it will treat it as a new variable I think this may have been taught in the beginner javascript videos) so I wouldn't call it a new convention especially because it is generally a bad practice to call a new variable without the var keyword in front of it. So to keep things short just treat that undeclared variable html as: var html; you should be able to figure it out from there ;)