Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Scope Chain Access

Behind the Sceneseasy

Course · Section 8: How JavaScript Works Behind the Scenes · Lecture 96: Scope and The Scope Chain

Implement `outer(x)` that defines an inner function reading `x` from the enclosing scope and returns `x + 10`. Call the inner function and return its result.

Sample tests

Input: outer(5)
Output: 15
Input: outer(0)
Output: 10

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Shadowing x with a parameter on the inner function.
Visualize this concept: Hoisting →
Approach & explanation (try first)

The inner function resolves x through the scope chain to its enclosing function.

Loading...
⌘/Ctrl + Enter

Run your code to see results.