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
flatten = (array, result) => { | |
if(array.length === 0) return result; | |
let head = array[0]; | |
let rest = array.slice(1); | |
if (Array.isArray(head)) { | |
return flatten(head.concat(rest), result); | |
}; | |
result.push(head); | |
return flatten(rest, result); |