Can't pass the steamroller tests

Can't pass the steamroller tests
0

#1

when i check the code in the console i find the result exact but for some reason i can’t pass the test cases

Your code so far


let result = [];
function steamrollArray(arr) {
  // I'm a steamroller, baby
  arr.forEach(e => {
    if (Array.isArray(e)) {
      steamrollArray(e);
    } else {
    result.push(e);
    }
    
  })
  return result;
}

console.log(steamrollArray([[["a"]], [["b"]]]));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller


#2

The variable result can not be a global variable, because the FCC tests run consecutively, so result would start as last value it ended with in the previous test. Put a console.log(result) in on the first line of your steamRollArray function and you will see what I mean.