title: Javascript map & aggregate nested JSON
body: <p>I'm newer to javascript and using JSON datasource trying to aggregate data in which i'd like to loop through nested JSON and add each &quot;vm&quot; element to another in a list, but keep getting the values repeated next to each.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let jsonData = [{
      "data": [{
              "name": "13_WH1",
              "attributes": {
                  "bv": 145
              },
              "vm": [
                  3.0,
                  2.0,
                  5.0,
                  5.0
              ]
          }
  
      ],
      "name": "category_one"
  },
  
  {
      "data": [{
              "name": "13_WH1",
              "attributes": {
                  "bv": 145
              },
              "vm": [
                  4.0,
                  8.0,
                  6.0,
                  6.0
              ]
          },
          {
              "name": "32_WH2",
              "attributes": {
                  "bv": 155
              },
              "vm": [
                  5.0,
                  7.0,
                  7.0,
                  2.0
              ]
          }
      ],
      "name": "category_two"
  }
  ]
  
  
  function sumVm(data_set) {
    data_set.map(function(series, index) {
      const total_vm = series.data.reduce(
        (accumulator, record) =&gt; accumulator + record.vm,
        0
      );
      console.log(total_vm)
      return total_vm
  
    })
  };
  
  console.log(sumVm(jsonData))</code></pre>
  </div>
  </div>
  </p>
  <p>When you execute the above code snippet you'll see the result doesn't add up each &quot;vm&quot; position.  My desired output would be like this:</p>
  <pre><code>12,17,18,13
  </code></pre>