Skip to content

Instantly share code, notes, and snippets.

@burnjohn
Last active March 16, 2019 12:16
Show Gist options
  • Save burnjohn/632b36152a38e91ddda75b1895dae60a to your computer and use it in GitHub Desktop.
Save burnjohn/632b36152a38e91ddda75b1895dae60a to your computer and use it in GitHub Desktop.
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