Why is my code not passing the given test when it gives the expected output
var final = [];
function steamrollArray(arr) {
// I'm a steamroller, baby
for (var i=0; i<arr.length; i++) {
checkArray(arr[i]);
}
return final;
}
function checkArray(a) {
if (Array.isArray(a)) {
performLoop(a);
} else {
final.push(a);
}
}
function performLoop(newArr) {
for (var i=0; i<newArr.length; i++) {
checkArray(newArr[i]);
}
}
steamrollArray([1, {}, [3, [[4]]]]);
Link to the challenge:
https://www.freecodecamp.org/challenges/steamroller