-
-
Save albertoperezf/2ee5e7a1c2003117c8e721187720a526 to your computer and use it in GitHub Desktop.
Sum arrays in one line
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
var arr = [ | |
1, | |
2, | |
3, | |
4, | |
5, | |
6 | |
]; | |
const sum = (arr) => arr.reduce((a, b) => a + b, 0); | |
sum(arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment