Tell us what’s happening:
Hi, so the question was to flatten/steamroll the array. And I know there are numerous answers in the hint section but I’m wondering why my answer isn’t working.
Thanks in advance
Your code so far
var tab=[];
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{
tab.push(arr[i]);
}
}
return tab;
}
steamrollArray([[["a"]], [["b"]]]);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/