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 trialken schafer
13,263 PointsWhy isn't the html variable declared?
in the code at the bottom you have
"html = "You got " + correctAnswers + " question(s) right." print(html);"
I am wondering why it's not
"var html = "You got " + correctAnswers + " question(s) right."
2 Answers
Steven Parker
231,236 PointsIt would have been "best practice" to include "var" in the initialization. But unless "strict" mode is being used, new variables are implicitly created as global when it omitted, so it works either way.
If you want, you could report this as a bug to the Support staff.
Lainey Odette
18,618 PointsDave declared the html variable at the top of the page when he added question and answer variables. :)
ken schafer
13,263 Pointsken schafer
13,263 Pointsthanks for the quick response. I was wondering if i was making a mistake somewhere and combing through to try and find where that var was declared.