Skip to content

Instantly share code, notes, and snippets.

@apolopena
Last active January 15, 2019 22:45
Show Gist options
  • Save apolopena/8541b98dca41865ad193f6896029c3ac to your computer and use it in GitHub Desktop.
Save apolopena/8541b98dca41865ad193f6896029c3ac to your computer and use it in GitHub Desktop.
JavaScript: double an array of number with a one-liner using rest, spread and recursion
function double([number, ...rest]) {
return !number ? [] : [number * 2, ...double(rest)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment