Skip to content

Instantly share code, notes, and snippets.

@fay-jai
Created November 14, 2018 17:09
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 fay-jai/16fc6652b90d23a440a646f5e0f72878 to your computer and use it in GitHub Desktop.
Save fay-jai/16fc6652b90d23a440a646f5e0f72878 to your computer and use it in GitHub Desktop.
// Variadic sum function in JavaScript - note that we'll be using some ES6 features here
const sum = (...args) => { // args get collected into an array
return args.reduce((acc, current) => acc + current, 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment