let restricts the scope of the variable to the current block
comparing var with let
WHEN using var for declaring a variable THEN the scope of the variable is the surrounding function
WHEN declaring a variable using let THEN the scope is limited to the surrounding block (enclosed in { and })
using let
WHEN using let in a for loop THEN the variable is only "visible" inside this loop
WHEN embedding a let variable in a block (using curly braces) THEN the variable is not "visible" outside of it
WHEN declaring a variable with let without a value THEN this variable has the value undefined
Related Katas
Block scope
letdeclarationconstdeclaration
Difficulty Level
BEGINNER
First Published
23 March 2015
Stats
5 tests to solve