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