Skip to content

Instantly share code, notes, and snippets.

@guerrerocarlos
Created May 28, 2014 23:20
Show Gist options
  • Save guerrerocarlos/0f130908bd30b43c52c1 to your computer and use it in GitHub Desktop.
Save guerrerocarlos/0f130908bd30b43c52c1 to your computer and use it in GitHub Desktop.
functional-javascript duckCount solution
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