Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am beuhug on github.
  • I am beuhug (https://keybase.io/beuhug) on keybase.
  • I have a public key ASDTpCi-E4CgIKarjDKMRDJ5Z_fbeCDbLU-y2A7HJwLHJgo

To claim this, I am signing this object:

@beuhug
beuhug / flatten.js
Created December 13, 2016 16:04
some code that will flatten an array of arbitrarily nested arrays
let flattener = function(nestedArray) {
return nestedArray.reduce((result, value) => {
let valueToConcat = Array.isArray(value) ? flattener(value) : value
return result.concat(valueToConcat)
}, []);
}
console.log(flattener([[1,2,[3]],4]))