Skip to main content
featured•daily challenge•javascript
0s
+25 XP

Featured Daily: Closure Variable Retention

What will this closure counter function return on its second call?

javascript
function createCounter() {
    let count = 0;
    return () => ++count;
}
const counter = createCounter();
counter();
console.log(counter());
Exit to Challenges