carName is undefined outside myFunction():
GLOBAL variable can be accessed from any script or function.
assign a value to a variable that has not been declared, it will automatically become a GLOBAL variable:
HTML, global variables defined with var, will become window variables.
HTML, global variables defined with let, will not become window variables.