freeCodeCamp Challenge Guide: Understanding Uninitialized Variables

freeCodeCamp Challenge Guide: Understanding Uninitialized Variables
0.0 0

#1

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”.

Basically this means that before you do any operations with them you must assign an initial value at some point.

the correct answer is :

// Initialize these three variables
var a=5;
var b=10;
var c=“I am a”;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";


#2

// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

var a = 6;
var b = 15;
var c = “I am a”;

What is wrong with this?


#3

var c should be initialised before it is used since it is a string. try initialising it right after declaration


#4

it should be -

var a = 5;
var b = 10;
var c = “I am a”;


#5

on var c should add ! after String. should be all set!