Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Created February 18, 2015 19:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasinhayder/60c4fa9ca16a31ab8763 to your computer and use it in GitHub Desktop.
Save hasinhayder/60c4fa9ca16a31ab8763 to your computer and use it in GitHub Desktop.
counter problem v 2
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