Intermediate Algorithm Scripting: Steamroller: I tried solving this problem with somewhat of recursion

Tell us what’s happening:

i tried solving this problem with recursion however i dont know if what i am doing is the correct way or if i am missing something it seems like i am close.

Your code so far

function steamrollArray(arr) {
let obj = []
let element

      element = arr
        return element
    else  if(arr == '[object Object]'){
    return JSON.stringify('{}')


   else if(Array.isArray(arr) ){




steamrollArray([1, {}, [3, [{},[4]]]]);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.

Challenge: Steamroller

Link to the challenge:

Generally it’s possible to do this with recursion, yes. As with recursion what need to be considered is an appropriate base case, and way recursive calls are made otherwise to get closer to the base case.

Notice that right now function not in every case is returning something, hence the undefined that can be observed in result.