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
// The nested array | |
const nested = [[1,2,[3,[8,10]]],4]; | |
// An array that will contain the flatten array | |
const flat = []; | |
// The function that runs through the array and flattens it | |
const scan = (el, arr) =>{ | |
if(!Array.isArray(el)) | |
throw "The first parameter should be an array"; | |
if(!Array.isArray(arr)) | |
throw "The second parameter should be an array"; |