function checkScope() {
let i = 'function scope';
if (true) {
let i = 'block scope';
console.log('Block scope i is: ', i);
}
console.log('Function scope i is: ', i);
return i;
}
Challenge: Compare Scopes of the var and let Keywords
You aren’t declaring it twice, it’s two different variables, the lesson is teaching scope. The curly brackets denote a scope here: inside the if block, you can declare variables that just live inside the scope.