Skip to content

Instantly share code, notes, and snippets.

@bunnyhawk
Created November 7, 2020 16:10
Show Gist options
  • Save bunnyhawk/8d1e804e056289ea17ad6cee9d9d322b to your computer and use it in GitHub Desktop.
Save bunnyhawk/8d1e804e056289ea17ad6cee9d9d322b to your computer and use it in GitHub Desktop.
arr.reduce((accumulator, currentValue, currentIndex, sourceArray) => {
// accumulator: the current running "total"
// currentValue: the current value of the arr (we are looping through them, one by one)
// currentIndex: where you are in the loop (0 based, as usual)
// sourceArray: access to the unmodified original arr array
// Return a function here leveraging the accumulator or currentValue
}, initialValue);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment