Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Last active February 7, 2020 16:16
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 AllGistsEqual/f1eda3aadb2020b7c850578acb0df12d to your computer and use it in GitHub Desktop.
Save AllGistsEqual/f1eda3aadb2020b7c850578acb0df12d to your computer and use it in GitHub Desktop.
function sum(...theArgs) {
return theArgs.reduce((previous, current) => {
return previous + current;
});
}
console.log(sum(1, 2, 3)) // 6
// expected output: 6
console.log(sum(1, 2, 3, 4)) // 10
// expected output: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment