Using for loops create new object with other objects with matching id's I'm not sure if this is the best way to write this code..

object.array.forEach((item) =&gt; {
  object.otherarray.array.forEach((asset) =&gt; {
    if(item.fields.image.sys.id === asset.sys.id) {
      item.fields.image['fields'] = asset.fields;
    }
  })
});


any help would be appreciated!
In this loop object.otherarray.array you use id property to to ensure to have necessary match. So I assume this item.fields.image.sys.id === asset.sys.id always should have only one match. And it resulted in the following code:

object.array.forEach((item) =&gt; {
    item.fileds.image.fields = object.otherarray.array.filter(
        (asset) =&gt; item.fields.image.sys.id === asset.sys.id
    )[0].fields;
});


Some explanation:

object.otherarray.array.filter(
        (asset) =&gt; item.fields.image.sys.id === asset.sys.id
    )[0];


is an equivalent of your item.fields.image.sys.id === asset.sys.id. In other words, firstly we find necessary asset. Then when we have it we can use fields property to assign it to item.fileds.image.fields.

I also have another variant of my remake:

object.array.forEach((item) =&gt; {
    const imageId = item.fields.image.sys.id;
    item.fileds.image.fields = object.otherarray.array
        .filter((asset) =&gt; imageId === asset.sys.id)
        [0].fields;
});


While it is more verbose version, it is more clear and structive so I would recommend to use this one.

I am open to your comments as I suppose I could not understand your correctly.

Edit: as @MarcRohloff said, you can use find instead of filter. But note, that `find has poor support in browsers:

object.array.forEach((item) =&gt; {
    const imageId = item.fields.image.sys.id;
    item.fileds.image.fields = object.otherarray.array
        .find((asset) =&gt; imageId === asset.sys.id)
        .fields;
});