var increment = () => { var counter = 0; var incrementCount = () => { counter = counter + 1; return counter; } return incrementCount; } counter = increment(); // call this like this counter() -> the first time will return 1 and then increment every time after