Steamroller code example
Example: Steamroller
const steamrollArray = (arr, finalArr = []) => {
arr.forEach(elem => {
if(Array.isArray(elem)){
steamrollArray(elem, finalArr)
}
else{
finalArr.push(elem)
}
});
return finalArr
}
const ans = steamrollArray([1, [], [3, [[4]]]]);
console.log(ans)