title: Get key name of a javascript object in an array of objects
body: <p>I have some <strong>Entries</strong>, those entries have a <strong>Category</strong> assigned to them, and each entry has a <strong>numeric Value</strong>;</p>
  <pre><code>{
     category: &quot;cat1&quot;,
     value: -100
  }
  </code></pre>
  <p>This is my entry ^. I run a Loadash <em>GroupBy</em> to group all the categories.</p>
  <pre><code>const groups = _.groupBy(dataSource, (entry) =&gt; entry.category);
  </code></pre>
  <p>This snippet here returns like this:</p>
  <pre><code>{
      &quot;cat1&quot;: [
          {
              category: &quot;cat1&quot;,
              value: -100
          },
          {
              category: &quot;cat1&quot;,
              value: +10
          },  
      ],
      &quot;cat2&quot;: [
          {
               category: &quot;cat2&quot;,
               value: -100
          },
          {
               category: &quot;cat2&quot;,
               value: +40
          },
          //and so on...
  }
  </code></pre>
  <p>The keys are the <strong>Category</strong> names. The objects are the related entries.</p>
  <p>I need to run a consecutive <em>Map</em> with an embedded <em>Reduce</em> to reduce the arrays to an integer through the sum of each entry's value.</p>
  <pre><code>const categoryValues = _.map(groups, (element) =&gt; {
      return {
          categoryName: ???????, 
          //*I DONT KNOW WHAT GOES HERE ^, 
          //I NEED THE NAME OF THE CATEGORY TO BE HERE*
          categoryValue: _.reduce(element,(acc, el) =&gt; el.value,0),
      };
  });
  </code></pre>
  <p>Thats because my graph api needs his dataset array to be formed by objects like this one:</p>
  <pre><code>{
     &quot;categoryName&quot;: &quot;cat1&quot;, //*THIS IS MISSING*
     &quot;categoryValue&quot;: 999
  }
  </code></pre>
  <p>How can I access the key name of each array? I need to know how the category is named, so that the graph will display its name.</p>
  <p>What needs to be written where I put my question marks?</p>