Last active
January 15, 2019 22:45
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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