Flatten an array using JavaScript | Beginner level | Code along with Vishal

preview_player
Показать описание
Hello folks,
This is a code along session where I talk about a few beginner level problems. Please leave a feedback!

Follow me -
Рекомендации по теме
Комментарии
Автор

bro extremely useful, plz also mention time complexity and brute force method. 😍

HyperXD_YT
Автор

function flatten(arr) {
let result = [];
for(let item of arr) {
if(Array.isArray(item)) {
result = result.concat(flatten(item));
}else {
result.push(item);
}
}
return result;
}

shivrajnag
Автор

bro just a question when you can solve it in one line of code using flat funtion eg:-
test.flat(Infinity)
why to do through recursive approach? 🤔

adobarman
Автор

bro just one doubt everytime we call recursion function so everytime result variable should reinitialized to "[ ]" right

vishwaksaransundarraj
Автор

Nice bro, also add a face cam on corners

KartheekRajDarkwarrior
join shbcf.ru