Skip to content

Instantly share code, notes, and snippets.

@anubhavsrivastava
Created February 3, 2019 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anubhavsrivastava/50236dde3561454708d57830398b1226 to your computer and use it in GitHub Desktop.
Save anubhavsrivastava/50236dde3561454708d57830398b1226 to your computer and use it in GitHub Desktop.
function add(){
let args = [].slice.apply(arguments);
function resultFn(){
args = args.concat([].slice.apply(arguments));
if(args.length>=3){
return args.slice(0,3).reduce(function(acc,next){ return acc+next},0)
}
return resultFn
}
return resultFn();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment