Created
          October 21, 2020 17:42 
        
      - 
      
- 
        Save ogwurujohnson/704eef6107e1706ace91ee27fc6d0d9d to your computer and use it in GitHub Desktop. 
    Reimplement lodash groupby
  
        
  
    
      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 users = [ | |
| { name: 'Jim', color: 'blue' }, | |
| { name: 'Sam', color: 'blue' }, | |
| { name: 'Eddie', color: 'green' }, | |
| ]; | |
| const usersByColor = users.reduce((acc, value) => { | |
| if (!acc[value.color]) { | |
| acc[value.color] = []; | |
| } | |
| acc[value.color].push(value); | |
| return acc; | |
| }, {}); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment