Sobes.tech
Junior — Senior

Console Output Challenge #98

livecode

Task condition

In this task, you need to understand what output will be displayed in the console when executing the program, considering the scoping rules of var and let. Pay attention to how a variable declared inside an if block 'shadows' a variable with the same name declared in an outer scope.

var outerB = 50;

function showValues() {
    console.log(outerB);
    if (true) {
        let innerB = 150;
        console.log(innerB);
    }
    console.log(outerB);
}

showValues();

Determine the order and values that will appear in the console when this code is run.