I see where are you’re struggling.
In JavaScript, variables can be Declared, Defined,Uninitialized and Initialized
(let me explain this programming terminology)
Declared:
We say a variable is declared when you’ve given a name to a variable, but you haven’t assigned it a specific value yet. For example:
let a; // It's a variable called "a"
A variable has two states, Uninitialized or Initialized
Uninitialized:
It’s when we created a variable, however we don’t give a value to it, for example:
let b; // it's a variable called "b", however doesn't have any value
Initialized:
Is the opposite of Uninitialized
, we say that a variable is Initialized
when we give value to the declared variable, for example:
var c; // We declare the variable called "c" (set a variable with a name but without a value)
c = 55; // Initialization of the variable "c" (meaning, giving a value to it), see that we don't need to add the prefix `var` again, because it's already set above
Defined:
Last, we say that a variable is defined when we declare and Initialize in a single step, for example:
var d = 55; // we created the variable "d" and initialized with a value of 55 at the same time
So having this concepts clear, we can take a look at your problem.
The lesson " Understanding Uninitialized Variables" gives you this piece of code:
// Only change code below this line
var a;
var b;
var c;
// Only change code above this line
a = a + 1;
b = b + 5;
c = c + " String!";
The first part:
var a;
var b;
var c;
As you can see, the code provides three variables with no values (how do we call these?)
a = a + 1;
b = b + 5;
c = c + " String!";
In the last part of the code, we can see that it doesn’t use the prefix var
meaning that it’s already set
So the lesson asks you:
- Initialize the three variables
a
, b
, and c
(It doesn’t say add new variable but Initialize the existing ones)
- Add the values
5
, 10
, and "I am a"
respectively, so the initial value of the variables doesn’t equal to undefined
.
Try solving it and let me know if you have any problem