Steamroller is this solution valid?

any input is appreciated,

   **Your code so far**
function steamrollArray(arr) {
 
 let myArr= arr 
 .join(" ")
 .replace(/Object/,"")  
 .replace(/[\s+\W+]/g," ")
 .replace(/\s+/g," ")
 
 .split(" ")
if(myArr.length ===2){ 
return myArr
}
else{
  return myArr.map((arrr) => isNaN(arrr)?{}:parseInt(arrr,10))
}
}
console.log(steamrollArray([1, [], [3, [[4]]]]))
   **Your browser information:**

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

Challenge: Steamroller

Link to the challenge:

It’s valid for passing the challenge, but not for flattening arrays. It should not modify stored values in any way.