Skip to content

Instantly share code, notes, and snippets.

@omartell
Created July 17, 2011 14:30
Show Gist options
  • Save omartell/1087646 to your computer and use it in GitHub Desktop.
Save omartell/1087646 to your computer and use it in GitHub Desktop.
A function that takes any number of args and returns the sum of them
function sumAll(){
var args = arguments;
if(args.length > 0) {
var element = args[args.length - 1];
var left = Array.prototype.slice.call(args, 0, args.length - 1);
return element + sumAll.apply(window, left) ;
}
else{
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment