Tell us what’s happening:
I tried to come up with a recursive solution but I can’t figure out why my console.log doesn’t do anything.
Your code so far
function steamrollArray(arr) {
//Vroommmmmm
let returner = [];
var func = function(ind) {
if(typeof (ind) != "array") {
returner.push(ind);
} else {
for(var x in ind) {
func(ind[x]);
}
arr.forEach(flatten);
console.log(returner);
}
}
}
steamrollArray([1, [2], [3, [[4]]]]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36
.
Challenge: Steamroller
Link to the challenge: