MCPcopy
hub / github.com/sudheerj/javascript-interview-questions / createCounter

Function createCounter

coding-exercise/closure-counter.js:1–7  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1function createCounter() {
2 let count = 0;
3 return function() {
4 count++;
5 return count;
6 };
7}
8
9const counter1 = createCounter();
10const counter2 = createCounter();

Callers 1

closure-counter.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected