Skip to content

Instantly share code, notes, and snippets.

@awave1
Last active December 27, 2019 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awave1/f70cbaa15c02d6bdcb977b2d0ad197ef to your computer and use it in GitHub Desktop.
Save awave1/f70cbaa15c02d6bdcb977b2d0ad197ef to your computer and use it in GitHub Desktop.
function sum(arr, i, j) {
return arr.slice(i, j).reduce((prev, current) => current += prev, 0);
}
console.log(sum([1, 2, 3, 4, 5], 1, 3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment