Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptclosures as a patternSingle-choice MCQ

This `counter` factory uses a closure to keep state private. What does the sequence of calls log?

function makeCounter() { let count = 0; return () => ++count; } const a = makeCounter(); const b = makeCounter(); console.log(a(), a(), b());