Java script functions

Exercise:- https://www.codecademy.com/courses/introduction-to-javascript/lessons/scope/exercises/block-scope-ii

Here you told that the scope of local variable is upto the particular block only.
But when I run this

function user(){
    {
        var name='xyz';
    }
    console.log(name);
}
user();

Why it not giving reference error although I am accessing console.log(name) from outer scope

1 Like

you can’t just go and insert an additional set of curly brackets/accolades ({}).

2 Likes