← All practice pages
JavaScript
JavaScript Closures
A closure is a function that remembers the variables around it after the outer function has finished. That is how each counter or handler keeps its own private state.
Try it now
Write a function "makeCounter" that uses a closure to return a counter function; each counter keeps its own independent count.
Create a free account to run your answer and get ARIA's review.