Skip to content

Instantly share code, notes, and snippets.

@BiosBoy
Created September 8, 2020 20:54
Show Gist options
  • Select an option

  • Save BiosBoy/6fd48b9e3410749d25d9267dbd84d3d8 to your computer and use it in GitHub Desktop.

Select an option

Save BiosBoy/6fd48b9e3410749d25d9267dbd84d3d8 to your computer and use it in GitHub Desktop.
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