Understanding Uninitialized Variables help please

You might want to go back to the start again and re-read the assignments, don’t rush it.

5 = a;

The left-hand side of the assignment operator is the receiver, you are trying to assign a variable to a primitive data type. You can not assign a value to 5, it is what it is, the number 5 and nothing else.

c = I am a;

The text on the right-hand side here is supposed to be a string, you use quotes "" or '' around text to make it a string “I am a”

This is declaring variables

var a;
var b;
var c;

This is initializing the variables

a = "some string";
b = 42;
c = b;

This is declaring and initializing the variables in one line.

var a = "some string";
var b = 42;
var c = b;
1 Like