I have two arrays of objectcs
const a = [ { "categoryId": 1, "categoryName": "category 1", "id": 11 }, { "categoryId": 2, "teamName": "category 2", "id": 22 } ] const b = [ { "categoryId": 2, "categoryName": "category 2", "id": 33 }, { "categoryId": 3, "categoryName": "category 3", "id": 44 } ] now I want to merge them together that the end result should look like:
const result = [ { "categoryId": 1, "categoryName": "category 1", "aId": 11, "bId" null: }, { "categoryId": 2, "categoryName": "category 2", "aId": 22, "bId" 33: }, { "categoryId": 3, "categoryName": "category 3", "aId": null, "bId" 44: } ] I don't see how I can assign the null values.
I've already tried it with Object.assign and with the "..." operator but don't get the result like wished.
In the same way I want to rename the id's to a new key depending on their array.
let result = a.concat(b) would give me a wrong result