Skip to content
Junior–Senior165 views

What will the console display after calling nested functions

Asked at

Task condition

Determine what will be printed to the console when the functions are called sequentially.

function outer() {
    let a = 1;
    return function inner() {
        a++;
        console.log(a);
    };
}

let fun1 = outer();
fun1();
fun1();
fun1();
let fun2 = outer();
fun2();
Frontend tasks in the code trainer