freecodecamp steamroller

Solutions on MaxInterview for freecodecamp steamroller by the best coders in the world

showing results for - "freecodecamp steamroller"
Livvy
13 Jan 2019
1const steamrollArray = (arr, finalArr = []) => {
2  arr.forEach(elem => {
3    if(Array.isArray(elem)){
4          steamrollArray(elem, finalArr)
5        }
6    else{
7      finalArr.push(elem)
8    }
9  });
10
11  return finalArr
12}
13
14const ans = steamrollArray([1, [], [3, [[4]]]]);
15console.log(ans)
queries leading to this page
steamrollerfreecodecamp steamroller