I was trying to understand the variable scoping in JavaScript. But I didn't understood why below code behaving different from the expected behavior.
'use strict';
function C() {
console.log(a);
}
function B() {
let a = 'printing A from B()';
C();
}
function A() {
let a = 'printing A from A()';
B();
}
const a = 'printing A from global context';
A(); // output getting: 'printing A from global context': CORRECT
B(); // output getting: 'printing A from global context' but expected : 'printing A from B()'
C(); // output getting: 'printing A from global context' but expected : 'printing A from A()'