你好,我是一位新手程序员,我遇到了一个问题,需要从两个数组中按日期对数据进行分组。
这是我的两个数组:
header = [
{"2019-04-22": "Sun, Apr 22, 2019"},
{"2019-04-21": "Sat, Apr 21, 2019"},
]
body = [
{"2019-04-22": "doing customer support”},
{"2019-04-22": "reply to emails"},
{"2019-04-21": "send message to customers"},
]
如何将多个数组合并为一个数组,如下所示的示例。
combinearray = {
"2019-04-22": [
"Sun, Apr 22, 2019",
"doing customer support",
"reply to emails",
],
"2019-04-21": [
"Sat, Apr 21, 2019",
"send message to customers",
],
}
对于我这个初学者来说,将两个数组数据按日期分组似乎非常困难。我需要JavaScript编程的任何答案。
combinearray
should be obj wrapped in{}
instead of[]
- Maheer Ali"2019-04-21": [ "Sat, Apr 21, 2019", "send message to customers"]
?你为每个单独的对象重复键 - 如果你只关心字符串部分,那么对象有什么意义呢? - Tyler Roper