title: Convert and eliminate duplicates in a JavaScript array to an ordinary object (containing arrays)
body: <p>In JavaScript I have an array that has site data in it:</p>
  <pre><code>var sites = [ 
    [&quot;Alabama&quot;, &quot;Huntsville&quot;], 
    [&quot;Tennessee&quot;, &quot;Nashville&quot;], 
    [&quot;Tennessee&quot;, &quot;Memphis&quot;], 
    {Tennessee, &quot;Knoxville&quot;], 
    [&quot;New Mexico&quot;, &quot;Los Alamos&quot;], 
    [&quot;New Mexico&quot;, &quot;Santa Fe&quot;] 
  ];
  </code></pre>
  <p>I need to convert it into an object such that the state names become the object keys and the city names are values in an array. This would also remove duplicate state names so the object would look like this:</p>
  <pre><code>var newSites = {
    Alabama: [&quot;Huntsville&quot;], 
    Tennessee: [&quot;Nashville&quot;, &quot;Memphis&quot;, &quot;Knoxville&quot;], 
    NewMexico: [&quot;Los Alamos&quot;, &quot;Santa Fe&quot;] 
  };
  </code></pre>
  <p>I've started programming something where I compare the state name in the array to the next state name in the array to combine like state names, but my logic is long and seems...messy.  (The state names are listed in alphabetical order, so my basic premise should work.  Also, the array will never have null or invalid values for either the state name or the city name.)</p>
  <p>Is there an eloquent way to output such an object?</p>