总和具有相同键的javascript对象值

时间:2020-05-08 08:44:36

标签: javascript arrays sorting datetime object

如果日期相同,我正在尝试添加点赞数。从我的代码中,我有相同的日期,但一天中的时间不同。我想添加当天的所有赞。这是日期数组对象

var date = [{text: "b", len: 1, Date: "Fri May 01 2020 10:49:01 GMT+0100 (West Africa Standard 
Time)", Source: "Twitter for Android", Likes: 1},
{text: "b", len: 1, Date: "Fri May 01 2020 10:50:03 GMT+0100 (West Africa Standard Time)", Likes: 1},
{text: "b", len: 1, Date: "Fri May 02 2020 10:55:03 GMT+0100 (West Africa Standard Time)",Likes: 4},
 {text: "b", len: 1, Date: "Fri May 02 2020 10:56:03 GMT+0100 (West Africa Standard Time)",Likes: 3},
 {text: "b they will neither comment not like this tweet", len: 47, Date: "Fri May 01 2020 11:35:49 
GMT+0100 (West Africa Standard Time)", Likes: 0}]

我想要

 `[{Date: May 01 2020, Likes:3}, {Date: May 02 2020, Likes:7}]`

0 个答案:

没有答案