Skip to content

Instantly share code, notes, and snippets.

@syntacticsugar
Created October 6, 2014 16:14
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 syntacticsugar/3055dd4dd8d4bc65ab52 to your computer and use it in GitHub Desktop.
Save syntacticsugar/3055dd4dd8d4bc65ab52 to your computer and use it in GitHub Desktop.
A simple JS recursion using slice.
function sum (numbers) {
return !numbers.length ? 0 : numbers[0] + sum(numbers.slice(1));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment