Created
August 19, 2014 09:39
-
-
Save cawhitworth/202eb5389bf2cf6b3079 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
var counter = function(start) { | |
var c = start || 0; | |
return function(amount) { | |
c = c + (amount || 1); | |
return c; | |
} | |
}(42); | |
console.log(counter()); // 43 | |
console.log(counter(5)); // 48 | |
console.log(counter()); // 49 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment