Intermediate Algorithm Scripting ,Steamroller problem is solved with map but does not work

var str=[];
function steamrollArray(arr) {
 
 
 arr.map(function(a){
 			if(Array.isArray(a)){
      	str=steamrollArray(a);
      }else{
      	str.push(a);
      }
 });
 
 return str;
}


steamrollArray([1, [2], [3, [[4]]]]);

Can someone help me understand why this answer is wrong?

Solutions that use global variables generally don’t work in the challenges. You’ll have to rewrite your code so that there are no globals.

1 Like

Opps! I did not know that! Thank you! :slight_smile: