Tell us what’s happening:
Describe your issue in detail here.
Can someone explain the purpose of 3 dots ‘…’ before the steamrollArray function? And how is this possible that a recursive function is not returning a value. I mean how will the calls unwind?
**Your code so far**
function steamrollArray(arr) {
var newArr = [];
for (var i = 0; i < arr.length; i++) {
if (Array.isArray(arr[i])) {
newArr.push(...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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Challenge: Steamroller
Link to the challenge: