title: Transform nested object of objects of arrays in JS
body: <p>Besides the horrible name of the question my question is quite simple. I have this object:</p>
  <pre><code>let test = {
    date1: [
      {
        time: 1,
        value: 5,
      },
      {
        time: 2,
        value: 6,
      },
    ],
    date2: [
      {
        time: 1,
        value: 20,
      },
      {
        time: 2,
        value: 10,
      },
    ],
  };
  </code></pre>
  <p>That I want to transform to something like this:</p>
  <pre><code>let result = {
    date1: {
      values: [5, 6],
      times: [1, 2],
    },
    date2: {
      values: [1, 2], // easier to summarise?!
      times: [10, 20],
    },
  };
  </code></pre>
  <p>I actually want to do this in order to summarise the <code>value</code>-values for each date. I thought that if I have them in an array it would be easier to summarise them. I know there are other forms to do this (and I'd be happy to see any solutions).</p>
  <p>My current approach does not what I want it to do. It looks like this:</p>
  <pre><code>let keys = Object.keys(test);
  let red = keys.reduce((acc, curr) =&gt; {
    return (acc[curr] = test[curr].map((e) =&gt; e.value));
  }, {});
  
  console.log(`red: `, red);
  </code></pre>
  <p>And produces this:</p>
  <p><code>red:  [ 20, 10 ]</code></p>