Tell us what’s happening:
My code give correct answer but it is not passing even a single test??
Can anyone explain why is it so?
Can I use arr.flat(Infinity) it gives answer in single line of code??
Your code so far
let answ = []
function steamrollArray(arr) {
for(let i = 0; i< arr.length; i++) {
let value = arr[i]
if(Array.isArray(value)) {
steamrollArray(value)
}
else answ.push(value)
}
return answ
}
console.log(steamrollArray([1, [2], [3, [[4]]]]))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
.
Link to the challenge: