Last active
May 24, 2019 17:26
-
-
Save bradfordlemley/886a4be1d6b31fa954e4545a95840e22 to your computer and use it in GitHub Desktop.
Vanilla counter with standardized state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function createCounter() { | |
let state = 0; | |
return { | |
get state() { return state }, | |
increment() { state = state + 1}, | |
decrement() { state = state - 1}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment