Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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