Scope of nested functions in JavaScript

If the function contains another function inside - the variables of the outer function are visible in the inner one:

javascriptfunction test() {
  let num = 1; // the external function variable
  
  function func() {
    console.log(num); // shows 1
  }
  
  func(); // calls the inner function
}

test(); // calls the external function

Also, variables defined outside the outer function will be visible in the inner function:

javascriptlet num = 1; // the global variable

function test() {
  function func() {
    console.log(num); // shows 1
  }
  
  func(); // calls the inner function
};

test(); // calls the outer function
Задание 1

Determine what will be output to the console without running the code:

javascriptfunction test() {
  let num = 1;
  
  function func() {
    console.log(num);
  }
  
  func();
}

test();
Задание 2

Determine what will be output to the console without running the code:

javascriptfunction test() {
  let num = 1;
  
  function func() {
    console.log(num);
  }
}

test();
Задание 3

Determine what will be output to the console without running the code:

javascriptfunction test() {
  let num = 1;
  
  function func() {
    console.log(num);
  }
  
  func();
}
Задание 4

Determine what will be output to the console without running the code:

javascriptfunction test() {
  let num;
  
  function func() {
    console.log(num);
  }
  
  num = 1
  func();
  
  num = 2
  func();
}

test();