Created
September 28, 2016 09:30
-
-
Save Joaquin6/a6b0279925c1d25aba70c3e709301ef3 to your computer and use it in GitHub Desktop.
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers in Node.js.
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
var _ = require("underscore"); | |
var nestedArray = [[1,2,[3]],4]; | |
var flattenArray = _.flatten(nestedArray); | |
console.log(flattenArray); | |
// => [1, 2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment