Hey guys,

Please help me to understand recursion better and the solution to the stamrollArray challenge. I have already watched different videos, but they all have only a basic explanation. I would be very thankful for your help.

After looking at the solutions of other people, I could come up with this solution, but I still do not understand why in order to call up the function again for recursion, It has to be pushed into a new array together with a spread operator (newArr.push(…steamrollArray(arr[i])))?

Why can’t I simply call up the function by writing (steamrollArray(arr[i])) without pushing it into a new array with a spread operator?

As far as I could understand if I simply call the function without pushing it into a new array, the new array will be empty with every new recursion.

If I am right, I really would like to know what happens behind the scene when I push the function into a new array? And why it must be pushed together with a spread operator?

Thank you in advance.

**Your code so far**

```
function steamrollArray(arr) {
let newArr = [];
for (let i=0; i<arr.length; i++){
if(!Array.isArray(arr[i])) {
newArr.push(arr[i])
} else {
newArr.push(...steamrollArray(arr[i]))
}
}
return newArr;
}
steamrollArray([1, [2], [3, [[4]]]]);
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/87.0.4280.88 Safari/537.36`

.

**Challenge:** Steamroller

**Link to the challenge:**