Created
February 18, 2015 19:39
-
-
Save hasinhayder/60c4fa9ca16a31ab8763 to your computer and use it in GitHub Desktop.
counter problem v 2
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(arg){ | |
arg = arg == undefined ? 1 : arg; | |
var me = arguments.callee; | |
return me.count ? ( me.count += arg, me.count ) : ( me.count = arg, me ); | |
} | |
var cnt = counter(5); | |
cnt(); | |
cnt(); | |
console.log(cnt(5)); //shud return 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment