The Secure Vault
Hard+40 XP
Mission Briefing
The Secure Vault needs a highly protected access counter that cannot be tampered with from the outside! You must craft a closure to securely enclose the count state.
The Concept: Private Variables
Closures are often used to create "private" variables. By defining a variable in the outer function and returning an inner function that modifies it, the outside world can never access the variable directly—they can only use the inner function!
The Objective
Your function createCounter receives an initial start number.
- Return an inner function.
- Every time the inner function is called, it should increment the count and return the new count.
Constraints
AdvancedClosures
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
start0
Expected Output
1
Click RUN to test your solution