title: Obtaining totals from properties of parallel arrays in nested objects
body: <p>I'm trying to obtain totals from properties that exist in objects in 'parallel' nested arrays. The data describes exercise sets.</p>
  
  <p>I'd like to populate the "totalWeight" fields with the sum of weight lifted for each exercise. The data structure is below. The total should be the "setNum" of the "reps" values x the "setNum" of the "Weight" values where the setNums exist in two parallel arrays. So for the first exercise (Dumbbell Shoulder press) the totalWeight should be 560 ((8 reps x 28 weight)+(6x28)+(6x28)). The measurement types are distinguished by the "mu_id" property from where the "key" property value is obtained.</p>
  
  <p>A complicating factor is that some exercises might have left-hand &amp; right-hand reps so there are 3 parallel arrays as in the second example of the One Arm Cable Front Raise. There, the totalWeight should be 265 ((8 lh reps + 8 rh reps )*6.25 weight)+((7+8)*6.25)+((10+9)*3.75)). </p>
  
  <p>The data structure was created by a d3.js nest routine from a flat database file but I haven't figured out how I can get these values either as part of the nesting (using rollup) or otherwise. I have access to d3.js but no other js libraries.</p>
  
  <pre><code>[
     {
        "exercise":"Dumbbell Shoulder press",
        "totalWeight":0,
        "values":[
           {
              "key":"1",
              "values":[
                 {
                    "resultsId":10381,
                    "setNum":"8",
                    "desc":"times",
                    "unit":"Reps",
                    "mu_id":1
                 },
                 {
                    "resultsId":10382,
                    "setNum":"6",
                    "desc":"times",
                    "unit":"Reps",
                    "mu_id":1
                 },
                 {
                    "resultsId":10383,
                    "setNum":"6",
                    "desc":"times",
                    "unit":"Reps",
                    "mu_id":1
                 }
              ]
           },
           {
              "key":"3",
              "values":[
                 {
                    "resultsId":10381,
                    "setNum":"28",
                    "desc":"kilograms",
                    "unit":"Weight",
                    "mu_id":3
                 },
                 {
                    "resultsId":10382,
                    "setNum":"28",
                    "desc":"kilograms",
                    "unit":"Weight",
                    "mu_id":3
                 },
                 {
                    "resultsId":10383,
                    "setNum":"28",
                    "desc":"kilograms",
                    "unit":"Weight",
                    "mu_id":3
                 }
              ]
           }
        ]  
     },
     {
        "exercise":"One Arm Cable Front Raise",
        "totalWeight":0,
        "values":[
           {
              "key":"3",
              "values":[
                 {
                    "resultsId":10395,
                    "setNum":"6.25",
                    "desc":"kilograms",
                    "unit":"Weight",
                    "mu_id":3
                 },
                 {
                    "resultsId":10396,
                    "setNum":"6.25",
                    "desc":"kilograms",
                    "unit":"Weight",
                    "mu_id":3
                 },
                 {
                    "resultsId":10397,
                    "setNum":"3.75",
                    "desc":"kilograms",
                    "unit":"Weight",
                    "mu_id":3
                 }
              ]
           },
           {
              "key":"7",
              "values":[
                 {
                    "resultsId":10395,
                    "setNum":"8",
                    "desc":"times",
                    "unit":"Reps (left)",
                    "mu_id":7
                 },
                 {
                    "resultsId":10396,
                    "setNum":"7",
                    "desc":"times",
                    "unit":"Reps (left)",
                    "mu_id":7
                 },
                 {
                    "resultsId":10397,
                    "setNum":"10",
                    "desc":"times",
                    "unit":"Reps (left)",
                    "mu_id":7
                 }
              ]
           },
           {
              "key":"8",
              "values":[
                 {
                    "resultsId":10395,
                    "setNum":"8",
                    "desc":"times",
                    "unit":"Reps (right)",
                    "mu_id":8
                 },
                 {
                    "resultsId":10396,
                    "setNum":"8",
                    "desc":"times",
                    "unit":"Reps (right)",
                    "mu_id":8
                 },
                 {
                    "resultsId":10397,
                    "setNum":"9",
                    "desc":"times",
                    "unit":"Reps (right)",
                    "mu_id":8
                 }
              ]
           }
        ]
     },
     {...}
  ]
  </code></pre>