function outer() { let counter = 0; function incrementCounter() { // we have access to counter here even though it's defined in the parent scope counter += 1; return counter; } return incrementCounter; } let myFunc = outer(); console.log(myFunc()); console.log(myFunc()); let other = outer(); console.log(other()); console.log(other());