Last active
          January 14, 2020 14:34 
        
      - 
      
 - 
        
Save zaguiini/480e0cf741d3d01ae518f6442bcfefde to your computer and use it in GitHub Desktop.  
    How to flatten a list using reduce and recursion
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const flattenList = (array) => { | |
| return array.reduce((flat, next) => { | |
| return flat.concat(Array.isArray(next) ? flattenList(next) : next) | |
| }, []) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
spread?