Counter via Closure

Closures ยท medium

Implement `runCounter(start, times)` that creates an internal counter starting at `start`, calls the increment function `times` times, and returns the final counter value. (This exercises building and using a closure internally.)

Hints
  • Create an inner function that captures and mutates `count`.
  • Call the inner function `times` times in a loop.

Learning resources

Loading...

Run your code to see results.