What is the difference between initializing a variable and assigning

this lesson is confusing me

even the title of it confuses me "Initializing Variables with the Assignment Operator
"

what does it mean to initialize a variable what it differs from the assigning the variable a value

Challenge: Basic JavaScript - Initializing Variables with the Assignment Operator

Link to the challenge:

let a;
console.log(a)//undefined >>> a initialized, but nothing assigned to a
a = 5;
console.log(a)//5 >>> value 5 was assigned to a

let b = 7
console.log(b)//7  >>> assignment and initializing done in the single line

console.log(c)//ReferenceError: c is not defined
1 Like

Initializing is when you first create and declare a variable, it can even be empty when you do this as you can see in admit8490’s example.

Assigning a value is when you use the equals sign to give it a value, and you can do this at initialization or at any other time, the only requirement is that you have at least initialized the variable at some point previously in the code, otherwise you may get an error for having an undeclared variable.