Hi camper, I’m having trouble completing this challenge. I’ve tried implementing Steamroller challenge through recursion and it seems that it won’t let me advance into the next challenge. Here’s the code:
function steamrollArray(arr) {
// I'm a steamroller, baby
function flattenArray(arr){
if(!Array.isArray(arr)) return arr;
return flattenArray(arr.reduce(x => flattenArray(x)));
}
return arr.map(x => flattenArray(x));
}
let test = steamrollArray([1, [2], [3, [[4]]]]);
console.log(test);