Well I think no one can answer this, gr8!

function steamrollArray(arr) { let newArray = arr.toString() newArray = newArray.split(/\,/g) console.log(newArray) newArray = newArray.map((val,i,arr) => { if (val == "[object Object]") { return {} } else if (val == "") { return "" } else if (val.match(/[a-z]/g)) { return val } else { return parseInt(val) } }) return newArray } console.log(steamrollArray([1, [], [3, [[4]]]])) console.log("actual result should be [1,3,4]")

so please help , how to remove the second element("") in newArray

Have a look at the splice() method:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice

1 Like