Created
December 1, 2017 10:58
-
-
Save gilesbradshaw/2a0207b00d77a730681c064f701b881b to your computer and use it in GitHub Desktop.
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 selectMany(func) { | |
return this.reduce( | |
(acc, val) => [ | |
...acc, | |
...func(val), | |
], | |
[], | |
); | |
} | |
['josh', 'steve', 'steve', 'craig']::selectMany(x => [x, `hello ${x}']); | |
/* [ | |
'josh', | |
'hello josh', | |
'steve', | |
'hello steve', | |
...etc | |
] | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment