Skip to content

Instantly share code, notes, and snippets.

@JasonDeving
Created March 19, 2016 22:28
Show Gist options
  • Save JasonDeving/9fd2cac2c95139447b77 to your computer and use it in GitHub Desktop.
Save JasonDeving/9fd2cac2c95139447b77 to your computer and use it in GitHub Desktop.
function counter
function counter() {
var n = 0;
return {
count: function() {return ++n; },
reset: function() {n = 0;}
}
};
var myCounter = counter(), num;
myCounter.count();
myCounter.count();
myCounter.reset();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment