我有一系列像这样的对象
const arrayOne = [
{ id: 'call_1', callDuration: 3 },
{ id: 'call_2', callDuration: 5 },
{ id: 'call_3', callDuration: 4 },
{ id: 'call_4', callDuration: 8 },
{ id: 'call_5', callDuration: 3 },
{ id: 'call_6', callDuration: 4 },
{ id: 'call_7', callDuration: 6 },
{ id: 'call_8', callDuration: 7 },
{ id: 'call_9', callDuration: 25 },
{ id: 'call_10', callDuration: 25 },
];
我需要从 arrayOne 中创建以下一个:
const arrayTwo = [
[
{ id: 'call_1', callDuration: 3 },
{ id: 'call_2', callDuration: 5 },
],
[
{ id: 'call_2', callDuration: 5 },
{ id: 'call_3', callDuration: 4 },
],
[
{ id: 'call_3', callDuration: 4 },
{ id: 'call_4', callDuration: 8 },
],
[
{ id: 'call_4', callDuration: 8 },
{ id: 'call_5', callDuration: 3 },
],
[
{ id: 'call_5', callDuration: 3 },
{ id: 'call_6', callDuration: 4 },
],
[
{ id: 'call_6', callDuration: 4 },
{ id: 'call_7', callDuration: 6 },
],
[
{ id: 'call_7', callDuration: 6 },
{ id: 'call_8', callDuration: 7 },
],
[
{ id: 'call_8', callDuration: 7 },
{ id: 'call_9', callDuration: 25 },
],
[
{ id: 'call_9', callDuration: 25 },
{ id: 'call_10', callDuration: 25 },
],
];
我想要的基本上是创建一个包含对象的新数组。我不知道如何处理这个问题。如果您有任何想法,请告诉我。
UYOU
相关分类