Created
May 28, 2014 23:20
-
-
Save guerrerocarlos/0f130908bd30b43c52c1 to your computer and use it in GitHub Desktop.
functional-javascript duckCount solution
This file contains hidden or 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 duckCount(){ | |
function Count(args,pos,count){ | |
if(pos<args.length) return Count(args,pos+1,count + Object.prototype.hasOwnProperty.call(args[pos], "quack") ? 1 : 0) | |
else return count | |
} | |
return Count(arguments,0,0); | |
} | |
module.exports = duckCount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment