DEV Community

Discussion on: JavaScript Var, Let, and Const

Collapse
 
sanamichael profile image
Sana Michael Yves

Hi, i don't understand why hello variable is not defined.
We know it has been declared like greeting variable.

Collapse
 
bello profile image
Bello Osagie • Edited

Because when let is used to create a variable within a block scope ({ ... }), the variable is only available in it. This type of variables are called local variables; while when var is used to create a variable within a block scope ({ ... }), the variable is available everywhere in the program (within or outside the scope). This type of variables are called global variables