title: Reformat an array of objects to an array of key'd arrays
body: <p>So I am kind of new to Javascript but I am trying to reformat the startArray into the endArray. The startArray is basically an array of order objects, which will always have different orderId's but can have the same companyId. I basically am trying to switch it so it's based on company, and so that for each companyId, there is an array of all of that companies orders. I have been tinkering and trying to figure this out, but to be honest I'm not sure where to start, or if this manipulation is even possible.</p>
  
  <p>I am working out of Google Apps Scripts, which I think is still on ES5 syntax, and I would prefer to stick to vanilla javascript if at all possible.</p>
  
  <pre><code>var startArray = [
      {"companyId" : 1,
       "orderId" : 25,
       "product" : "productA"
       "quantity" : 2,
       "price" : 10,
      },
      {"companyId" : 1,
       "orderId" : 20,
       "product" : "productB"
       "quantity" : 3,
       "price" : 5,
      },
     {"companyId" : 2,
       "orderId" : 15,
       "product" : "productA"
       "quantity" : 5,
       "price" : 10,
      }
   ]
  
   var endArray = [ {
        '1' = [{"orderId" : 25,
           "product" : "productA"
           "quantity" : 2,
           "price" : 10,},
           {"orderId" : 20,
            "product" : "productB"
            "quantity" : 3,
            "price" : 5,}
        },{
       '2' = [{"orderId" : 15,
            "product" : "productA"
            "quantity" : 5,
            "price" : 10,
           }]
     }]
  
  
   ]
  </code></pre>