Why is scope concept not working here , kindly guide

@kevcomedia - no i understand one does not write code like you explained, i was just asking why JS which claims to be compiled language as suggested by kyle simpson as well as crockford, two famous authors on JS …

What is the point of restricting itself from looking down in the same scope for a variable value and print it , rather then print undefined … Thanks