Created
March 19, 2016 22:28
-
-
Save JasonDeving/9fd2cac2c95139447b77 to your computer and use it in GitHub Desktop.
function counter
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
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