Skip to content

Instantly share code, notes, and snippets.

@Silva97
Last active August 30, 2018 23:07
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 Silva97/4ebe20f00de1f60917103b9abdb54381 to your computer and use it in GitHub Desktop.
Save Silva97/4ebe20f00de1f60917103b9abdb54381 to your computer and use it in GitHub Desktop.
function sum(...args){
var result = 0;
if(args.length == 4){
for(let i = 0; i < args.length; i++)
result += args[i];
return result;
} else {
return function(...newArgs){
return sum(...args, ...newArgs);
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment