var vs let

introduction to the `let` keyword for declaring block-scoped variables; and the dangers of scoping, such as the temporal dead zone

Variables declared with var have function scope. This means that they are accessible inside the function/block they are defined in. Take a look at the following code:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.