Understanding Uninitialized Variables i need help

Tell us what’s happening:

Your code so far


// Initialize these three variables
var a;
a = 5; //the variable "a" is equal to 5
a = a + 1;
var b;
b = 10; //the variable "b" is equal to 10
b = b + 5;
var c; 
c = "I am a"; //the variable "c" is equal to "I am a"
c = c + " String!";

// Do not change code below this line

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables

Hi @hencol , welcome to the forum.
You are failing the test because the variables are not equal to the value you’ve been asked to provide (5, 10 and “I am a”).

When you do a = a + 1; you are setting the value of a to its current value + 1 (so it becomes 6).
You should remove the extra 3 lines of code.

Edit: also you can combine instantiation and initialization of a variable in a single line like this:
var IAmAStringVariable = "StringValue";

1 Like