Thanks for this! I'm not quite so familiar with recursion at this point, but already I find it beautiful. blaketruelove
Thanks for this! I'm not quite so familiar with recursion at this point, but already I find it beautiful.
This is exactly what i was looking for. Thanks this is going to be very helpfull!!! cristhianmorales
This is exactly what i was looking for. Thanks this is going to be very helpfull!!!
Great video! Super helpful to watch you work through it without cutting away... Ombibulous_Bluegrass
Great video! Super helpful to watch you work through it without cutting away...
Nice. Thank you that was useful to me! JulienReszka
Nice. Thank you that was useful to me!
why do we concat? why cant we just call flatten(value) if its aray? soulrider
why do we concat? why cant we just call flatten(value) if its aray?
I get what's going on but probably need a more written out detailed step by step picture to see the mechanics of things if ya'll know what I mean rogerh
I get what's going on but probably need a more written out detailed step by step picture to see the mechanics of things if ya'll know what I mean
Without concat : const data = [[0, 1, 2], [3, 4, 5, [0, 0, 0, [6, 6, 6]]], [6, 7, 8]]; let flattenArr = []; const flatten = (data) => { if(Array.isArray(data)) { data.forEach(item => flatten(item)); } else { flattenArr.push(data); } return flattenArr; } console.log(flatten(data)); victoreliot
Without concat : const data = [[0, 1, 2], [3, 4, 5, [0, 0, 0, [6, 6, 6]]], [6, 7, 8]]; let flattenArr = []; const flatten = (data) => { if(Array.isArray(data)) { data.forEach(item => flatten(item)); } else { flattenArr.push(data); } return flattenArr; } console.log(flatten(data));