Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Gena Israel
2,047 Pointswhat is the point of var html = '';
var html = ''
2 Answers

Alexander Gyger
14,237 PointsWith
var html = '';
you define that (html) is a string(text)-variable. ('') contains a specific, but empty text. After this definition you can add other strings (+ 'other string') to it later.
If you don't define this (html) as a string-variable, just only the variable:
var html;
it will give you an ugly "undefined"-Error in the output, since the script will try to add a string to a variable which isn't defined.

Chris Thomas
Front End Web Development Techdegree Graduate 34,897 PointsIt's declaring an empty string variable to be used later. You can write it with either single quotes or double quotes.
var html = '';
var html = "";
and then later you might set it to something like
html = 'string';
or
html = "string";

Gena Israel
2,047 Pointsso it just a space so if i wrote prompt('Hello' + html +'Mom') It would say Hello Mom ?

Chris Thomas
Front End Web Development Techdegree Graduate 34,897 PointsOnly if you put a space in the variable.
var html = '';
is not the same as
var html = ' ';
Seth Roope
6,471 PointsSeth Roope
6,471 PointsThis is correct. You are just setting the type of the variable by defining it as an empty string.