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
    
  
  
    
  | // Accepts the array and key | |
| const groupBy = (array, key) => { | |
| // Return the end result | |
| return array.reduce((result, currentValue) => { | |
| // If an array already present for key, push it to the array. Else create an array and push the object | |
| (result[currentValue[key]] = result[currentValue[key]] || []).push( | |
| currentValue | |
| ); | |
| // Return the current iteration `result` value, this will be taken as next iteration `result` value and accumulate | |
| return result; | 
  
    
      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
    
  
  
    
  | public void loadProducts() { | |
| InputStream inputStream = getFileFromResourceAsStream("products.csv"); | |
| try (InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); | |
| BufferedReader reader = new BufferedReader(streamReader)) { | |
| String line; | |
| line = reader.readLine(); | |
| line = reader.readLine(); | |
| while ((line = reader.readLine()) != null) { |