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
/* | |
Write some code, that will flatten an array of arbitrarily nested arrays of | |
integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]. | |
*/ | |
var array_flatten = function (arr, flattened_arr = []) { | |
if(!Array.isArray(arr)) { | |
// Fow now, arbitrarily decide to just break out if input is invalid. Could handle other ways (return an empty array, for example), but this is OK for now. | |
console.error('Invalid input.'); | |
return; |