Created
August 27, 2017 22:53
-
-
Save zckly/5dbf5da03a99389b7f443bfb99c1bfbb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Takes an arbitrarily nested array of integers | |
//Returns a flattened copy of that array | |
export default function flatten (arr) { | |
//Initialize | |
const result = [].concat(...arr); | |
return result.some(Array.isArray) ? flatten(flat) : result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment