Skip to content

Instantly share code, notes, and snippets.

@adamgiese
Created July 17, 2018 13:43
Show Gist options
  • Save adamgiese/fddfd05dcecc48246ec20011ef5fd610 to your computer and use it in GitHub Desktop.
Save adamgiese/fddfd05dcecc48246ec20011ef5fd610 to your computer and use it in GitHub Desktop.
Declarative Arrays: Naming Callbacks
const newEngland = [0,3,6,19,6];
const atlanta = [0,21,7,0,0];
const toScore = (accumulator, value) => accumulator + value;
const atlantaScore = atlanta.reduce((accumulator, value) => accumulator + value);
const newEnglandScore = newEngland.reduce(toScore);
console.log(Math.max(newEnglandScore, atlantaScore));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment