Ed

The module pattern uses closures to create private variables that can't be accessed from outside. It's how we had encapsulation before ES6 classes!

Your Task:

  • Create a createCounter() function (no args)
  • Return an object with: increment(), decrement(), getCount(), reset()
  • The count itself should be PRIVATE (not accessible directly)
  • getCount() is the only way to read the value
TypeScript Solution
Loading...

Submit your code to see test results