Local variables in JavaScript functions

Variables defined within a function are called local. Unlike global variables, local variables are only visible inside the function, and not visible from the outside:

function func() { let num = 5; // the local variable console.log(num); } console.log(num); // will not output anything, but will throw an error to the console

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

function func() { let num = 5; return num; } console.log(num);

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

function func() { let num = 5; return num; } console.log(func());
enru