Each part of your JavaScript code is executed in an “execution context,” which dictates what variables are available.
Source Code
function outer() {
let a = 1;
function inner() {
let b = 2;
console.log(a + b); // 3
}
inner();
}
outer();