Skip to content

Instantly share code, notes, and snippets.

@timgarciaa
Created July 2, 2022 13:32
Show Gist options
  • Save timgarciaa/a7ead4a8e74ec3aa4fc0a5acc9fbee66 to your computer and use it in GitHub Desktop.
Save timgarciaa/a7ead4a8e74ec3aa4fc0a5acc9fbee66 to your computer and use it in GitHub Desktop.
Add numbers of array using reduce
const numbers = [1, 2, 3, 4, 5];
const result = numbers.reduce((current, next) => current + next, 0);
console.log(result);
// 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment