JSFiddle - React, Tailwind, and code Playground

by John Wick

JavaScript

var checklistTabs = [
    {
        "id": "64b151ebef990e2e99b88369",
        "sizingModelId": "636bc79efcce4821689dc1f3",
        "intendedContact": "c1",
        "label": "Tab1"
    },
    {
        "id": "64ba5f8e443a504467e6acca",
        "sizingModelId": "636bc79efcce4821689dc1f3",
        "label": "Tab2",
        "intendedContact": "636bc79a2b52b645b805bfba",
    },
    {
        "id": "64baa750443a504467e7a746",
        "sizingModelId": "636bc79efcce4821689dc1f3",
        "label": "New Tab",
        "intendedContact": "c2"
    }
]

var rowData = {
  documents: [{
    id: 1,
    name: 'doc1',
    intendedContactId: 'c1',
    intendedPropertyId: 'p1'
  }, {
    id: 2,
    name: 'doc2',
    intendedContactId: 'c2',
    intendedPropertyId: 'p2'
  }]
}

/* for (let i = 0; i < checklistTabs?.length; i++) {
  if (checklistTabs?.[i]?.intendedContact) {
    for (let j = 0; j < rowData?.documents?.length; j++) {
      if (rowData?.documents?.[j]?.intendedContactId === checklistTabs?.[i]?.intendedContact) {
        console.log('found', j, rowData?.documents?.[j]?.name)
      }
    }
  }
} */

for (const tab of checklistTabs) {
    if (tab.intendedContact) {
        const matchingDocument = rowData.documents.find(doc => doc.intendedContactId === tab.intendedContact);
        if (matchingDocument) {
            console.log('found', matchingDocument.id, matchingDocument.name);
        }
    }
}