Answers for "Freecodecamp Steamroller"

0

Freecodecamp Steamroller

const steamrollArray = (arr, finalArr = []) => {
  arr.forEach(elem => {
    if(Array.isArray(elem)){
          steamrollArray(elem, finalArr)
        }
    else{
      finalArr.push(elem)
    }
  });

  return finalArr
}

const ans = steamrollArray([1, [], [3, [[4]]]]);
console.log(ans)
Posted by: Guest on February-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language