Skip to content

Instantly share code, notes, and snippets.

@adamjgrant
Last active August 29, 2015 14:20
Show Gist options
  • Save adamjgrant/3097e2404c47b70daaa8 to your computer and use it in GitHub Desktop.
Save adamjgrant/3097e2404c47b70daaa8 to your computer and use it in GitHub Desktop.
function sum() {
return [].reduce.call(arguments, function(a, b) {
return a + b;
});
}
@adamjgrant
Copy link
Author

Calling sum() with as many parameters as you like, will add them up.

For example, sum(1, 2, 3, 4) will return 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment