Skip to main content

Practice ยท 2 of 3

Closure-Based Rate Limiter

Write createLimiter(maxCalls) that returns a function. The returned function returns true the first maxCalls times it is invoked and false after that. Example with createLimiter(2): true, true, false, false, ... This is how click-debouncing and API throttling are usually structured โ€” state captured in a closure, no globals.

Difficulty: intermediate

Back to lesson: Practice: Closures โ€” Practice