The count is declared inside the returned function, so it starts again every call.
Acceptance criteria
- 1.#out should show 1,2,3.
The count is declared inside the returned function, so it starts again every call.
function makeCounter() { return function () { let count = 0; count++; return count; }; } const c = makeCounter(); document.querySelector('#out').textContent = [c(), c(), c()].join(",");
Output ready when you are
Press Run to render your code, or Submit to validate your solution.