You must use the keyword ''var'' to create and initialize a variable. The placement of the variable creation in your code is very important.
Examples:
var first = 21;
var second = "a string"
var myBoolean = true;
Variables can either be global or local.
Global - the variable is accessible by all parts of the script.
Local - the variable is accessible only by the function in which it is defined.
Example: