Streamroller: console.log doesn't work

Hello,
I made this code, it’s similar to FCC solution 1 but it doesn’t work.
Where is the mistake ? and why “console.log” doesn’t work here ?

function steamrollArray(arr) {
  const result = [];
  for (let i = 0; i < arr.length; i++) {
    if (Array.isArray(arr[i])) {
      result.push(...steamrollArray(arr[i]));
    } else {
      result.push(arr[i])
    }
  }
  console.log(result)
}

steamrollArray([1, [2], [3, [[4]]]]);

Console logging is not the same thing as returning a value.

yes with both it’s ok. Of course!
My class sessions are too far apart right now. I’m losing my reflexes.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.