title: Combine arrays to one array
body: <p>lets say i have the following array, how can i achieve the last given example in my this question by modifing the given reduce function?</p>
  <p>i have tried to assign [cur] to a plans key but it only puts the first element out.</p>
  <p>i have the feeling it have something to do with the way i concat the objects but i cant figure it out on my own.</p>
  <pre><code>{
     employee: 'employee_1',
     customer: {
       name: 'customer_1',
     },
     startdate: '2020-03-01T23:00:00.000Z'
  }, {
     employee: 'employee_2',
     customer: {
       name: 'customer_1',
     },
     startdate: '2020-03-01T23:00:00.000Z'
  }, {
     employee: 'employee_3',
     customer: {
       name: 'customer_1',
     },
     startdate: '2020-03-01T23:00:00.000Z'
  }
  </code></pre>
  <pre><code>plans.reduce(function(o, cur) {
  
     // Get the index of the key-value pair.
     var occurs = o.reduce(function(n, item, i) {
        return (item.customer.toString() === cur.customer.toString()) ? i : n;
     }, -1);
  
     // If the name is found,
     if (occurs &gt;= 0) {
        // append the current value to its list of values.
        o[occurs].employee = o[occurs].employee.concat(cur.employee)
        o[occurs].startdate = o[occurs].startdate.concat(cur.startdate)
  
     // Otherwise
     } else {
  
        // add the current item to o (but make sure the value is an array).
        var obj = {
           customer: cur.customer,
           employee: [cur.employee],
           startdate: [cur.startdate]
        };
        o = o.concat([obj]);
     }
     return o;
  }, [])
  </code></pre>
  <p>this reduces the given array to something like this:</p>
  <pre><code>{
     customer: {
       name: 'customer_1'
     },
     employee: [{
       employee: 'employee_1'
     }, {
       employee: 'employee_2'
     }, {
       employee: 'employee_3'
     }],
     startdate: [{
       startdate: '2020-03-01T23:00:00.000Z'
     }, {
       startdate: '2020-03-01T23:00:00.000Z'
     }, {
       startdate: '2020-03-01T23:00:00.000Z'
     }]  
  }
  </code></pre>
  <p>But what i need is something like this:</p>
  <pre><code>{
     customer: {customer_data},
     plans: [{
       employee: 'employee_1',
       startdate: '2020-03-01T23:00:00.000Z' 
     }, {
       employee: 'employee_2',
       startdate: '2020-03-01T23:00:00.000Z' 
     }, {
       employee: 'employee_3',
       startdate: '2020-03-01T23:00:00.000Z' 
     }]
  }
  </code></pre>