Tell us what’s happening:
Hey everyone! My code works for me, and it’s logging the proper thing to the console too, however it’s not passing any of the FCC tests, I wonder what I’m doing wrong?
Thanks a lot in advance!
Your code so far
function nest(el) {
if (!Array.isArray(el)) {
return el;
}
return nest(el[0]);
}
let newArr = [];
function steamrollArray(arr) {
arr.forEach( (el) => {
if (!Array.isArray(el)) {
newArr.push(nest(el));
}
else {
el.forEach(el => {
newArr.push(nest(el));
})
}
})
return newArr;
}
steamrollArray([1, [2], [3, [[4]]]]);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/75.0.3770.90 Chrome/75.0.3770.90 Safari/537.36
.
Link to the challenge: