My code passes fails all the automated tests, but when I manually check it seems like it should pass and actually does return the right value. Am I doing something wrong here?
var myArr = [];
function steamrollArray(arr) {
// for each element in the array
for(var i = 0; i < arr.length; i++){
// if that element is an array itself
if(Array.isArray(arr[i])){
// call the steamroller function on that element
steamrollArray(arr[i]);
} else {
// once you get to an element that is not an array, push that to element to the global myArr array.
myArr.push(arr[i]);
}
}
return myArr;
}
steamrollArray([1, [], [3, [[4]]]]);
//returns [1, 3, 4];