Tell us what’s happening:
My code works, yet it doesn’t work on FreeCodeCamp. Can anyone help?
Your code so far
var newarr=[];
function steamrollArray(arr) {
// I'm a steamroller, baby
for (let i=0; i<arr.length;i++){
if (Array.isArray(arr[i])){
steamrollArray(arr[i])
} else {
newarr.push(arr[i]);
}
}
return newarr;
}
console.log(steamrollArray([1, [2], [3, [[4]]]]));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller