Multiple sums of object efficiently d3.js

Viewed 114

I have a object like:

{
  [

      {  id: "AL01",
         list: [
                  { speed : 5
                    value : 10} , 
                  { speed : 7
                    value : 15}
               ]
     }, 
     {  id: "AB01",
        list: [
                { speed : 20
                  value : 1} , 
                { speed : 8
                  value : 10}
              ]
     }

 ]

}

and i would like to have this result like:

{[ {  id: "AL01", speed: 12, value: 25}, {  id: "AB01", speed: 28, value: 11}]}

How can i get this efficiently? If is it possible to run only one time the functions map or forEach? I'm wondering something which go by only one time per each object.

2 Answers
Related