Created
November 7, 2020 16:10
-
-
Save bunnyhawk/24c73f6472e215fa8b88dcf7b165c724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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