I am trying to flatten the array regardless of the level. I run it in debugger.it is working well until the last curly bracket

后端 未结 0 862
灰色年华
灰色年华 2021-02-19 20:31
function flatten(arg){
  const d=[];
  
if(!Array.isArray(arg)){
  d.push(arg);
  
}else{
flatten(arg.reduce((a,b)=>a.concat(b))); 
}
return d;
}

console.log(flatten         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题