Considering the following snap of code, what is the expected result?
const gotNumber = 46; if (gotNumber>45) { let division = 'Second Division'; } console.log(`Division is ${division} by number ${gotNumber}`);
Considering the following snap of code, what is the expected result?
const gotNumber = 46; if (gotNumber>45) { let division = 'Second Division'; } console.log(`Division is ${division} by number ${gotNumber}`);
const gotNumber = 46; if (gotNumber>45) { let division = 'Second Division'; } console.log(`Division is ${division} by number ${gotNumber}`);
Variable declared by let
is block scope variable. So the variable division
is only accessible from the if condition block. Ultimately the result is: Error: division is not defined