Last active
March 16, 2019 12:16
-
-
Save burnjohn/632b36152a38e91ddda75b1895dae60a to your computer and use it in GitHub Desktop.
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
const counter = (function (argument) { | |
let count = 0; | |
const increase = () => { | |
count++ | |
}; | |
const decrease = () => { | |
count-- | |
}; | |
const getCount = () => count; | |
const setCount = (newCount) => { | |
count = newCount; | |
}; | |
return { | |
increase, | |
decrease, | |
setCount, | |
getCount | |
}; | |
})(); | |
counter.setCount(5); | |
counter.increase(); | |
counter.decrease(); | |
counter.decrease(); | |
console.log('Curr count: ', counter.getCount()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment