I tried to use the code below to get for the Intermediate Algorithm Scripting: Steamroller challenge. The thing is that it keeps saying that I failed it even though on the console the array shown is the expected answer.
function steamrollArray(arr) {
// I'm a steamroller, baby
let arrFlat = [];
for(let i = 0; i < arr.length; i++){
if(Array.isArray(arr[i])){
if(arr[i].length === 0){
continue;
}
arrFlat.push(steamrollArray(arr[i]));
}else{
arrFlat.push(arr[i]);
}
}
//console.log(arrFlat);
return [...arrFlat];
}
let d = steamrollArray([[["a"]], [["b"]]]);
console.log(d);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller/