Sum of same object name in javascript

前端 未结 4 1459
[愿得一人]
[愿得一人] 2021-01-16 04:33

Hi friends I\'m beginner for javascript how i sum same n no\'s of object name corresponding value and push the result to new array.see this is sample object

va

4条回答
  •  别那么骄傲
    2021-01-16 05:12

    var obj_1 ={'delivered':10,'due':11,'team_name':'UK'};
    var obj_2 ={'delivered':10,'due':11,'team_name':'US'};
    var obj_nth ={'delivered':10,'due':11,'team_name':'UK'};
    
    function sum_all() { 
        var sum={}; 
        for(var i=0;i

    Your console output will be:

    sum
    Object
      UK: Object
          delivered: 20
          due: 22
    
      US: Object
          delivered: 10
          due: 11
    

提交回复
热议问题