Please enable JavaScript to use CodeHS

Chapter 2

JavaScript Control Structures

2.11 Local Variables and Scope

What Are Local Variables?

What is Scope?

Why Scope Matters

Return Values and Scope

Other Scope Examples

Check Your Understanding

  1. Incorrect Correct No Answer was selected Invalid Answer

Exercise: Local Variables

Vocabulary

Term Definition
Indentation Indentation is the visual structure of how your code is laid out. It uses tabs to organize code into a hierarchy.
Variable A symbol or container that holds a value.
Scope In what part of the program the variable exits
Global variable A variable that can be used throughout a program, in every scope
Local variable A variable that is restricted to use in a certain scope of a program
Parameter A variable passed in from outside the function