Steamroller steamroller

Steamroller steamroller
0

#1

hi campers , I got stuck in this challenge
he is my try

function steamrollArray(arr) {
  // I'm a steamroller, baby
let flat=[];
  for (let i=0;i<arr.length;i++){
      var element=arr[i];
      if(typeof arr[i]==="number"){
          flat.push(arr[i]);
      }
 
      else if(Array.isArray(arr[i])){
          
         for (let j=0;j<arr[i].length;j++){
             element=element[j];
             if(typeof element==="number"){
                 flat.push(element);
             }
             else {
                 j=j-1; //I am trying to stay in the same index to get a number .
                 
             }
         }   
      }     
  }
    return console.log(flat)
  
}

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

give a sign please ,and is there a proper way to stay in the same index when we use loop.
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/


#2

Please post the link to the challenge now and in the future. It would make helping you more convenient.

So far, your steamroll doesn’t take into account an array inside an array.