Skip to content

Instantly share code, notes, and snippets.

@albertoperezf
Created June 15, 2017 12:02
Show Gist options
  • Save albertoperezf/2ee5e7a1c2003117c8e721187720a526 to your computer and use it in GitHub Desktop.
Save albertoperezf/2ee5e7a1c2003117c8e721187720a526 to your computer and use it in GitHub Desktop.
Sum arrays in one line
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