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.
- Make
getSecretreturn an inner function. - The inner function should simply return the
secretWordvariable.
Constraints
AdvancedClosuresScope
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
secretWord"JavaScript"
Expected Output
JavaScript
Click RUN to test your solution