Skip to content

Instantly share code, notes, and snippets.

@niktariy
Created January 8, 2020 11:50
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 niktariy/c60eefd11e25ae9f4b0bc8afd126a703 to your computer and use it in GitHub Desktop.
Save niktariy/c60eefd11e25ae9f4b0bc8afd126a703 to your computer and use it in GitHub Desktop.
Arrow function with ...rest parameter
const average = (...args) => {
if (args.length == 0) return 0;
const sumReduceFn = function (a, b) { return a + Number(b) };
return args.reduce(sumReduceFn, 0) / args.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment