Skip to content

Instantly share code, notes, and snippets.

Avatar

Carlos Rene Cerrato Estrada ccerrato147

View GitHub Profile
View flatArray.js
// 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";
You can’t perform that action at this time.