How to traverse an array and merge the objects in the array if the values of the objects in the array are equal

1. Traverse an array and merge the objects in the array if the values of the objects in the array are equal

//
var a = [
    {
      date:"2018-7-24",
      value:2
    },
    {
      date:"2018-7-24",
      value:5
    },
    {
      date:"2018-7-25",
      value:5
    },
    {
      date:"2018-7-25",
      value:5
    },
]
//
res = [
    {
      date:"2018-7-24",
      value:7
    },
    {
      date:"2018-7-25",
      value:10
    },

]

if you want to break your head, you still don"t know if anyone has a better way. Thank you very much!

Mar.29,2021

Why is there always such a problem these days.


arr.reduce((previousValue, currentValue, currentIndex, arr) => {

})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4682e-44bd3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4682e-44bd3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?