Steamroller exercise

Dear fellows,

Could somebody assist me with steamroller exercise I would like to know why the below code is not functioning properly especially with the recursive method.

here is my code

function steamrollArray(arr) {
 return flat(arr);
}

var flat=function(arr2)
{
  var result=[];
 while(arr2.length!==0)
   {
     if(Array.isArray(arr2[0])===false)
       {
         result.push(arr2[0]);
         arr2.shift();
       }
     else
     {
       flat(arr2[0]);
       arr2.shift();
       
     }
     
   }
  
  return result;
};

steamrollArray([1, [2]]);

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.