how to merge two arrays, put the remark corresponding to id in data2 into the id corresponding to data1, and the final result is data3
const data1 = [
{ "id": 1, "url": "1111" },
{ "id": 2, "url": "111" },
{ "id": 3, "url": "22222" },
{ "id": 4, "url": "222" },
{ "id": 5, "url": "2222" },
{ "id": 6, "url": "22222" }
]
const data2 = [
{ "id": 1, "remark": "1" },
{ "id": 2, "remark": "2" },
{ "id": 3, "remark": "" },
{ "id": 4, "remark": "" },
{ "id": 5, "remark": "" },
{ "id": 6, "remark": "beizhu6" }
]
function fun(arr1, arr2) {
arr1.map(item => {
arr2.map(item2 => {
if (item.id == item2.id) {
}
});
});
arr2 = [];
return arr1
}
fun(data1,data2);
data3=[
{ "id": 1, "url": "1111", "remark": "1" },
{ "id": 2, "url": "111", "remark": "2" },
{ "id": 3, "url": "22222", "remark": "" },
{ "id": 4, "url": "222", "remark": "" },
{ "id": 5, "url": "2222", "remark": "" },
{ "id": 6, "url": "22222", "remark": "beizhu6" }
]