-
-
Save ianstarz/4c22a218fa3a410c8d404c4548abd5da 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
[0, ['a', 'b', 'c'], 2, 'd', 4, 5, 'f', 7, ['g', 'h'], 9].reduce(function rec (prev, curr) { | |
if (/array/i.test(curr.constructor)) { | |
return curr.reduce(rec, prev); | |
} else if (/string/i.test(curr.constructor)) { | |
prev.push(curr); | |
} | |
return prev; | |
}, []); | |
//["a", "b", "c", "d", "f", "g", "h"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment