【发布时间】:2022-11-17 15:53:08
【问题描述】:
我有一个这样的对象数组
let data =
[
{
text: 'label'
},
{
text: 'username'
},
{
text: 'category'
},
{
text: 'book'
},
{
text: 'john'
},
{
text: 'education'
},
{
text: 'car'
},
{
text: 'doe'
},
{
text: 'automotive'
},
{
text: 'shoes'
},
{
text: 'cena'
},
{
text: 'fashion'
},
]
和我期望的对象数组
let result =
[
{
label: 'book',
username: 'john',
category: 'education'
},
{
label: 'car',
username: 'doe',
category: 'automotive'
},
{
label: 'shoes',
username: 'cena',
category: 'fashion'
},
]
【问题讨论】:
-
到目前为止你尝试了什么?
-
我试过取模,但我仍然堆叠结果
标签: javascript node.js arrays typescript object