Skip to content

Instantly share code, notes, and snippets.

@kuldeepkeshwar
Created May 23, 2019 07:29
Show Gist options
  • Save kuldeepkeshwar/e7d8f4ffffc5b88b77260a761f01e73e to your computer and use it in GitHub Desktop.
Save kuldeepkeshwar/e7d8f4ffffc5b88b77260a761f01e73e to your computer and use it in GitHub Desktop.
function flatten(arr){
return arr.reduce((result,item)=>{
if(Array.isArray(item)){
result=result.concat(flat(item))
}else{
result.push(item)
}
return result;
},[])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment