0

My first guess is that the following code has the output of 10 and 100. However, after running the code I get undefined and 100 and I don't understand why the function doesn't see the first declaration of x..

var x = 10;
function f() {
   console.log(x);
   var x = 100;
   console.log(x);
}
f();
connexo
  • 53,704
  • 14
  • 91
  • 128
qwerty2121
  • 13
  • 8

0 Answers0