Skip to content

Instantly share code, notes, and snippets.

@bunnyhawk
Created November 7, 2020 16:10
Show Gist options
  • Save bunnyhawk/24c73f6472e215fa8b88dcf7b165c724 to your computer and use it in GitHub Desktop.
Save bunnyhawk/24c73f6472e215fa8b88dcf7b165c724 to your computer and use it in GitHub Desktop.
// Standard
[1, 2, 3, 4, 5, 6, 7].reduce((total, num) => total + num);
// Reusable functional style
const add = (...nums) => nums.reduce((total, num) => total + num);
add(1, 2, 3, 4, 5, 6, 7);
// Returns: 28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment