I\'m a beginner with JavaScript so please be patient =)
I am trying to write a function that counts the number of times it is called. What I have so far is a functi
A one liner option:
const counter = ((count = 0) => () => count++)()
Usage example:
> counter() 0 > counter() 1 > counter() 2 > counter() 3 > counter() 4 > counter() 5 > counter() 6