对对象数组的某个数值类型字段的值进行累加

Posted Felix_Openmind

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了对对象数组的某个数值类型字段的值进行累加相关的知识,希望对你有一定的参考价值。

    const programmerOutput = [
        
          name: "Wangzz",
          outPrice: 112.23,
        ,
        
          name: "Wangxx",
          outPrice: 431.223,
        ,
        
          name: "Wangio",
          outPrice: 10.23,
        ,
        
          name: "wangz.",
          outPrice: 12.32
        
      ]
      let totalOutPrice = programmerOutput.map((coder) => coder.outPrice)
          .reduce((acc, outPrice) => (acc + outPrice),0)
      console.log("totalOutPrice: ", totalOutPrice) // totalOutPrice:  566.003

以上是关于对对象数组的某个数值类型字段的值进行累加的主要内容,如果未能解决你的问题,请参考以下文章