Skip to content

Instantly share code, notes, and snippets.

@adamgiese
Created July 17, 2018 12:59
Show Gist options
  • Select an option

  • Save adamgiese/1aa40099b6bf66c470a218a8b7af1dcc to your computer and use it in GitHub Desktop.

Select an option

Save adamgiese/1aa40099b6bf66c470a218a8b7af1dcc to your computer and use it in GitHub Desktop.
Declarative Arrays: Sum reducer
const numbers = [1,2,3,4,5];
const sum = numbers.reduce(
(accumulator, currentValue) => accumulator + currentValue
);
console.log(sum); // 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment