I have 2 arrays of objects with below structure:
array1 = [
  {
    categoryID: 'C1',
    links: [
      (0: {
        id: 1,
        linkID: 'A',
      }),
      (1: {
        id: 2,
        linkID: 'B',
      }),
    ],
  },
  {
    categoryID: 'C2',
    links: [
      (0: {
        id: 1,
        linkID: 'C',
      }),
      (1: {
        id: 2,
        linkID: 'D',
      }),
    ],
  },
];
array2 = [
  {
    categoryID: 'C1',
    links: [
      (0: {
        id: 1,
        linkID: 'A',
      }),
      (1: {
        id: 2,
        linkID: 'E',
      }),
    ],
  },
  {
    categoryID: 'C3',
    links: [
      (0: {
        id: 1,
        linkID: 'F',
      }),
    ],
  },
];
I want my result to be like below since both arrays have categoryID : 'C1' they should both get combined into one categoryID : 'C1' and the duplicate links[] items should get combined in this one category. ex.: linkID : "A' was common in both arrays thus should get combined:
[
  {
    categoryID: 'C1',
    links: [
      (0: {
        id: 1,
        linkID: 'A',
      }),
      (1: {
        id: 2,
        linkID: 'B',
      }),
      (3: {
        id: 3,
        linkID: 'E',
      }),
    ],
  },
  {
    categoryID: 'C2',
    links: [
      (0: {
        id: 1,
        linkID: 'C',
      }),
      (1: {
        id: 2,
        linkID: 'D',
      }),
    ],
  },
  {
    categoryID: 'C3',
    links: [
      (0: {
        id: 1,
        linkID: 'F',
      }),
    ],
  },
];
Please help me out with the javascript code for it which will be compatible for IE-11 or lower IE versions.
I have already tried .map(), .reduce() but either these are not compatible in IE11 or I am doing something wrong.
 
     
    