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

A common 'private counter' factory looks like the code below. After the two `inc()` calls, what does `c.value` report?

function makeCounter() { let count = 0; return { inc() { count++; }, get value() { return count; } }; } const c = makeCounter(); c.inc(); c.inc(); console.log(c.value);