Steamroller Coding Challenge

I tried to use the code below to get for the Intermediate Algorithm Scripting: Steamroller challenge. The thing is that it keeps saying that I failed it even though on the console the array shown is the expected answer.

function steamrollArray(arr) {
  // I'm a steamroller, baby

  let arrFlat = [];

  for(let i = 0; i < arr.length; i++){
      if(arr[i].length === 0){

  return [...arrFlat];

let d = steamrollArray([[["a"]], [["b"]]]);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:

Does not show for me. In my console I am getting: d = [[[a]], [[b]]] when it should be d = [a, b]. :frowning:

Can you show us a screenshot of what you are seeing in your browser’s console (Ctrl+Shft+J in Chrome)?

You are doing recursion wrong. You are calling the upper function in recursion which resets the arrFlat[]

There are two ways to resolve this.

  1. Create a new function inside which keep the logic.

  2. Move the arrFlat[] outside the function at the top

Well it has been a while, just to update I was able to complete the challenge and learned a valuable lesson in not trusting the console on the site especially when it comes to arrays.