It looks like I’m getting the correct output (according to console.log call immediately before return statement), but still failing the tests. A picture says a thousand words: https://i.imgur.com/hRa3xHS.png
**Your code so far**
function steamrollArray(arr) {
var done = true;
//assume this is the last iteration (all nested arrays are flattened)
for (let i = 0; i < arr.length; i++) {
if (Array.isArray(arr[i])) {
done = false;
//check our assumption and change it if needed
}
}
if (done) {
console.log(arr);
return arr;
//return the final array
} else {
var newArr = arr.reduce((a, b) => a.concat(b), [])
steamrollArray(newArr)
//perform one "layer" of flattening and call the function again
}
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0
.
Challenge: Steamroller
Link to the challenge: