An undefined variable is a variable that is used in a program that has not been previously declared in the source code. In most programming languages, this results in an error.
X = 1; // causes an error
To fix this, the variable can be defined and then assigned the value:
x = 1; // no error
Var x = 1; // variable declared and assigned a value
With this in place, the x variable won't have a value of "undefined".