Intermediate Algorithm Scripting - Steamroller

Tell us what’s happening:
I already figured out the recursive function, but for whatever reason I cannot push the primitive elements to a new array.

Your code so far

function steamrollArray(arr) {
  let newArr = []
  for (let x of arr) {

    if (Array.isArray(x) == true ) { 
    else {
   return newArr

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/ Safari/537.36

Challenge: Intermediate Algorithm Scripting - Steamroller

Link to the challenge:

Yes, you are making a recursive call here, but what are you doing with the return value?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.