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 Simplify Repetitive Tasks with Loops For Loops

Giorgi Gonadze
Giorgi Gonadze
3,640 Points

javascript

Why var html is assigned to an empty string? instead of var html = ""; could we write down just var html;?

1 Answer

Dehn Hunsworth
Dehn Hunsworth
7,189 Points
var html;

would create the variable but not set it to any one data type. this will leave it more versatile which could be good or bad depending on what your doing with it later in the script. A little more context on what your doing with it might help.

Moderator Edit: Moved response to Answer section