Skip to content

Instantly share code, notes, and snippets.

@vineeshnp
Created November 12, 2017 16:57
Show Gist options
  • Save vineeshnp/7abdb1c36197b9f0fb65052ea0c93937 to your computer and use it in GitHub Desktop.
Save vineeshnp/7abdb1c36197b9f0fb65052ea0c93937 to your computer and use it in GitHub Desktop.
Sum of an array in Javascript
const arr = [1, 2, 4, 5, -3]
var sum = arr.reduce((a, b) => a + b, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment