Tell us what’s happening:
The Steamroller exercise test for not using flat or flatMap fails, yet my solution does not use either.
Your code so far
function steamrollArray(arr) {
const flatten = (arr) =>
arr.reduce((acc, cur) =>
acc.concat(Array.isArray(cur) ? flatten(cur) : cur), []);
return flatten(arr);
}
steamrollArray([1, [2], [3, [[4]]]]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: Steamroller
Link to the challenge: