V.Vidhya Logo

V.Vidhya

Scope in Functions


Q1.

What will be the output of the following code?

You have to predict the output yourself without running/executing the code.

let greet = "hello";

function outerGreet() {
    let greet = "hi";

    console.log(greet);

    function innerGreet() {
        console.log(greet);
    }
}

console.log(greet);

outerGreet();

Prev Post
Functions Cumulative I
Next Post
Functions Cumulative II