Working on the steamroller problem (https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller); my code is below, issue is with the if statement.
function steamrollArray(arr) {
// I'm a steamroller, baby
let flattened = [];
for (var i = 0; i< arr.length; i++) {
console.log("is position "+i+" an array? "+Array.isArray(arr[i]));
} if (Array.isArray(arr[i]) == true) {
console.log("entering recursion");
steamrollArray(arr[i]);
} else {
flattened.push(arr[i]);
}
return flattened;
}
However, I never see any recursion and the console never logs “entering recursion.” (This also happens even if I remove == true from the if statement, not that that should make a difference in this context.) Can anyone explain why that is not working please? Thanks.