flatten array recursively

PHOTO EMBED

Sun Jun 05 2022 02:02:30 GMT+0000 (UTC)

Saved by @joeclaap #javascript #fibonacci #recursion #algorithm

function flatten(arr) {
  let flat = []
  
  for(let prop of arr){
    if(Array.isArray(prop)){
      flat.push(...flattan(prop))
    } else {
      flat.push(prop)
    }
  }
  return flat
}
content_copyCOPY