A variable declared inside a block using 'var'

Question | Dec 4, 2017 | hkumar 

enter image description here

A variable 'y' is defined in global scope, and another variable of same name is defined inside an 'if' block in function foo:

var y = 4; // Global scope

function foo(x) {
 if(x)
  var y = 3;

 return y;
}

// Call foo and log 
console.log(foo(1));

What will be logged on console?