Tell us what’s happening:
I created a function to be repeated that clears arrays by using join. It works fine if all arrays have the same number of inner arrays. For whatever reason, the if statement doesn’t seem to be working because it reports, typeError: x[i].join(’’); is not a function. I’m guessing it says that because individual strings cannot be joined. Which is why I included the (if) statement. Why isn’t that working?
Your code so far
function steamrollArray(arr) {
// I'm a steamroller, baby
function reReduce(x){
for ( i = 0; i<x.length; i++ ){
if ( typeof x[i][0] !== undefined ){//x[i][0] found here
x[i] = x[i].join('');//runs regardless of x[i][0]
}
}
return x;
}
var newArr = reReduce(arr);
return newArr;
}
steamrollArray([1, [2], [3, [[4]]]]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36.
Link to the challenge:
https://www.freecodecamp.org/challenges/steamroller