Last active
August 16, 2017 06:00
-
-
Save astfarias/0f808dd601f4f0cbc14557a4f2a679dd to your computer and use it in GitHub Desktop.
JS - Functional Programming - Higher-order Functions - reduce()
This file contains hidden or 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
| //Iterate under array to add values with reduce() | |
| var numbers = [0, 1, 5, 7, 3, 8, 9, 10]; | |
| var total = numbers.reduce( function( sum, nextValue ) { | |
| return sum + nextValue | |
| },0) | |
| // 43 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment