Why does the console.log return undefined? Even if let
limits the scope of v
, that scope is within the if
statement (which is also where the console.log
is), so shouldn't it still get logged?
var x = 1;
if(x < 10) {
let v = 1;
v = v + 21;
v = v * 100;
v = v / 8;
console.log(v);
}
console.log(v); //v is not defined