Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Well done!

You have completed (UPI) Chapter 4: Mastering JavaScript Basics: Operators, Variable Scope, and Data Handling!

Instruction

Function Scope

Function Scope

A function creates its own scope. Variables declared in the function's scope cannot be accessed from outside.

"use strict";
function func_1() {
 let x = 5; // x can only be used in func_1
 alert("Inside function: " + x);
}
func_1();
alert(x); // Causes an error

The function scope is sometimes called the local scope because this was the name in ol...