Tell us what’s happening:
freeCodeCamp Challenge Guide: Steamroller
I am getting correct output but still it is not accepting it.
This has happened to me before. I don’t like using hints often but for problems like these I am forced to use the hints .
Can anyone help me with a solution to this glitch or mistake in my program?
Your code so far
function steamrollArray(arr) {
return arrayrec(arr);
}
const sol=[];
function arrayrec(arr){
for(let i in arr){
if(JSON.stringify(arr[i]) == '{}'){
sol.push(JSON.stringify(arr[i]));
}
if(typeof arr[i] != "object")
sol.push(arr[i]);
else{
arrayrec(arr[i]);
}
}
return sol;
}
var a= steamrollArray([1, {}, [3, [[4]]]]);
console.log(a);
for(var i in a){
console.log(typeof a[i]);
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36
.
Challenge: Steamroller
Link to the challenge: