How can I merge multiple arrays into multiple separate objects?

I have an object that has multiple arrays that looks something like this.

let obj = { 
    links: ["https://somelink.com/image.jpg", "https://somelink.com/image2.jpg"],
    IDs: ["yCmj", "4q1K"],
}

I want to make it so that it’s turned into an array of objects. Like the following.

let newObj = {
   templates: [
      {id:"yCmj", link: "https://somelink.com/image.jpg"}, 
      {id:"4q1K", link: "https://somelink.com/image2.jpg"}
   ] 
}

What I have tried:

I tried mapping the object values to a new array but the second map overwrites the whole array.

let templates = obj.templateIDs.map((id) => ({id}))
templates = obj.thumbnailLinks.map((thumbnailLink) => ({thumbnailLink}))

let newObj = templates

Answer

The easiest way to accomplish this would be to pick either obj.links or obj.IDs and map their values to an object and use the index to locate the corresponding parallel value.

const obj = {
  links: ["https://somelink.com/image.jpg", "https://somelink.com/image2.jpg"],
  IDs: ["yCmj", "4q1K"],
};

const newObj = {
  templates: obj.links.map((link, index) => (id => ({ id, link }))(obj.IDs[index]))
};

console.log(newObj);
.as-console-wrapper { top: 0; max-height: 100% !important; }