Last active
May 30, 2019 07:28
-
-
Save vasanthv/272dd3676a971567f943c62490edce51 to your computer and use it in GitHub Desktop.
A function to get all possible combination of arrays.
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
const arr = [ [ '8', '0', '5', '7', '9' ], [ '1', '2', '4' ] ] | |
const output = arr.reduce((a, b) => { | |
let ret = []; | |
a.forEach(i => b.forEach(j => ret.push(i + j))); | |
return ret; | |
}); | |
// output = [ '81', '82', '84', '01', '02', '04', '51', '52', '54', '71', '72', '74', '91', '92', '94' ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment