【发布时间】:2021-08-16 05:04:44
【问题描述】:
我有一个要求,我有这种格式的数据。我怎样才能或最好和最容易获得以下格式的输出?
users = [
{
id: "1",
name: "Norah"
},
{
id: "2",
name: "Alyx"
}
];
accounts = [
{
account: "IRA-4679",
user: "1",
balance: "5175.36"
},
{
account: "AAA-3571",
user: "1",
balance: "3106701.85"
},
{
account: "AAA-4671",
user: "1",
balance: "138971.19"
},
{
account: "ROT-1687",
user: "2",
balance: "2686.00"
},
{
account: "AAA-7894",
user: "2",
balance: "68761.32"
},
{
account: "IRA-6818",
user: "2",
balance: "564.67"
},
{
account: "IRA-6819",
user: "2",
balance: "6564.67"
}
];
输出
["Norah | AAA-6818 | 564.67","Norah | AAA-4671 | 138971.19"]
是否与拆分数组并根据 id 合并为一个有关,或者我应该在这里做什么?
【问题讨论】:
-
你的输出不正确,能更新一下吗?
标签: javascript arrays sorting arraylist