Consider the following code
var scope = "global scope";
function checkscope() {
console.log(scope);
var scope = "local scope";
console.log(scope);
}
checkscope();
This prints the following in the console
undefined
local scope
Why is the first console.log printing undefined instead of "global scope"?