title: String manipulation in JavaScript array using lodash
body: <p>I have a JavaScript array which looks like this:</p>
  
  <pre><code>var arr = ["[Dim1].[Mem1].&amp;[1]",
             "[Dim2].[Mem1].&amp;[2]",
             "[Dim1].[Mem1].&amp;[5]",
             "[Dim2].[Mem1].&amp;[77]",
             "[Dim3].[Mem1].&amp;[1]"
            ]
  </code></pre>
  
  <p><strong>I want output in this format:</strong></p>
  
  <pre><code>{
      [Dim1].[Mem1].&amp;[1], [Dim1].[Mem1].&amp;[5]
  },
  {
       [Dim2].[Mem1].&amp;[2], [Dim2].[Mem1].&amp;[77]
  },
  {
       [Dim3].[Mem1].&amp;[1]"]
  }
  </code></pre>
  
  <p>The idea is to split each value based on '.&amp;' and then group by the result[0].</p>
  
  <p>I am able to do this by:</p>
  
  <ol>
  <li>Loop over all the items in array &amp; then split them with .&amp;</li>
  <li>Create another list based on [dim].[mem] combination. In our case the list will have [Dim3].[Mem1], [Dim1].[Mem1], [Dim2].[Mem1].</li>
  <li>Now have two loop - One for every item in unique list and one for every item in original list &amp; check if the item is original list contains the current item in unique list &amp; then form the string.</li>
  </ol>
  
  <p>How can I achieve this using "lodash" or any other JS based library which will reduce the code and make the method compact?</p>