Tell us what’s happening:
i am trying to solve this challenge, i approached this problem with a recursion and when i console log the result seems fine but freecodecamp is not accepting it.
Your code so far
function steamrollArray(arr) {
let result = []
let index = [];
let obj = []
if(!Array.isArray(arr)){
result.push(arr)
}
else {
arr.map(item=>{
if(item == '[object Object]'){
index.push(JSON.stringify(item))
}
else{
index.push(steamrollArray(item))
}
})
}
result+=index
obj = result
console.log(obj)
return obj;
}
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: