How to sum property values of an object?

后端 未结 5 1086
时光说笑
时光说笑 2021-01-20 00:46

I want to sum the property values of PieData. My expected output is 25515512+916952499 = 942468011



        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-20 01:23

    PieData is an array with 2 elements, each element being a HashTable. you can sum them up by saying:

    var sum = PieData[0]["value] + PieData[1]["value"]
    

    If you have more elements or simply want to use a loop:

    var sum=0;
    for(var i=0;i

提交回复
热议问题