Created
September 8, 2020 20:54
-
-
Save BiosBoy/6fd48b9e3410749d25d9267dbd84d3d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const setValue = state => { | |
| this.state = state || 0 | |
| this.set = value => { | |
| this.state += value | |
| return setValue(this.state) | |
| } | |
| this.get = () => this.state | |
| return { | |
| set: this.set, | |
| get: this.get | |
| } | |
| } | |
| const result = setValue().set(12).set(32).set(5).get() | |
| console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment