Skip to content

Instantly share code, notes, and snippets.

@Yago
Last active November 28, 2018 13:27
Show Gist options
  • Save Yago/a2ed962a8a4b9d540151435416a711e9 to your computer and use it in GitHub Desktop.
Save Yago/a2ed962a8a4b9d540151435416a711e9 to your computer and use it in GitHub Desktop.
const sum = (...args) => {
return args.reduce((acc, n) => typeof n === 'number' ? acc + n : acc, 0);
}
sum(31,7,4); // return 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment