The Persistent Memory

Hard+35 XP

Mission Briefing

The Memory Core is losing power and resetting variables! You must build a persistent cell that strictly remembers its internal secret long after the outer function has finished running.

The Concept: Closures

A Closure is created when a function is bundled together with references to its surrounding state (the lexical environment). This means an inner function "remembers" variables from its outer function even if the outer function has returned!

The Objective

Your function getSecret receives an outer variable secretWord.

  1. Make getSecret return an inner function.
  2. The inner function should simply return the secretWord variable.

Constraints

    AdvancedClosuresScope
    JavaScript
    Loading...
    3 Hidden

    Input Arguments

    secretWord"JavaScript"

    Expected Output

    JavaScript

    Click RUN to test your solution