title: Creating a SUM of nested object values in JavaScript
body: <p>I'm using the following code to query an API, which is working well to return nested values in JSON:</p>
  
  <pre><code>const obj = response.data.map(function(item) {
  
  return [item.id, item.jobNumber];
  });
  </code></pre>
  
  <p>Example JSON:</p>
  
  <pre><code>{
   "data": [
    {
       "id": 100,
       "jobNumber": 1,
       "jobTasks": [
          {
             "id": 12,
             "cost": {
                "amountString": 100
             },
             {
             "id": 13,
             "cost": {
                "amountString": 500
             }
           }
       }
    ]
  },
    {
       "id": 101,
       "jobNumber": 2,
       "jobTasks": [
          {
             "id": 14,
             "cost": {
                "amountString": 100
             },
            {
             "id": 15,
             "cost": {
                "amountString": 200
             }
           }
       }]
  
  }]
  }
  </code></pre>
  
  <p>I'm wanting to now loop through the nested Job Tasks, and SUM the <strong>item.jobTasks.cost.amountString</strong> for each job, So that the following could be returned:</p>
  
  <ul>
  <li>JobNumber1: Task Costs: 600 </li>
  <li>JobNumber2: Task Costs: 300</li>
  </ul>