Understanding Uninitialized Variables – freeCodeCamp

When JavaScript variables are declared, they have an initial value of undefined. If you do a mathematical operation on an undefined variable your result will be NaN which means “Not a Number”. If you concatenate a string with an undefined variable, you will get a literal string of undefined.

// Only change code below this line
var a;
a =5;
var b;
b=10;
var c ="I am a";
// Only change code above this line

a = a + 1;
b = b + 5;
c = c + " String!";
0 0 votes
Article Rating
Was this article helpful?
YesNo
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Scroll to Top