I have 2 arrays mentioned below.
const arr1 = [{ Id: "a153O000001mjD1QAI", Document_ID__c: 176767 }];
const arr2 = [
{
classification: "Scientific Response",
core_san_localization_translation: ["No"],
core_san_verbal_only: "false",
id: "176767",
major_version_number: "1",
minor_version_number: "0",
name: "Advance Search Doc_General Information",
response_type: ["General"],
size: 70953,
subtype: "Local",
title: "Advance Search Doc_General Information",
type: "Medical Information",
},
{
classification: "Scientific Response",
core_san_localization_translation: ["No"],
core_san_verbal_only: "false",
id: "127462",
major_version_number: "1",
minor_version_number: "0",
name: "APPROVAL verdict APPROVED FOR USE",
response_type: ["Administration"],
size: 1362339,
subtype: "Local",
title: "ahsdjhsahdasld",
type: "Medical Information",
},
{
classification: "Scientific Response",
core_san_localization_translation: ["No"],
core_san_verbal_only: "false",
id: "127461",
major_version_number: "2",
minor_version_number: "0",
name: "APPROVAL verdict APPROVED ,MINOR CHANGES",
response_type: ["Administration"],
size: 1362339,
subtype: "Local",
title: "ahsdjhsahdasld",
type: "Medical Information",
},
{
classification: "Scientific Response",
core_san_answer: "Dosage",
core_san_localization_translation: ["No"],
core_san_verbal_only: "false",
id: "176776",
major_version_number: "1",
minor_version_number: "0",
name: "General Info Test 2",
response_type: ["Pharmacokinetics and Pharmacodynamics"],
size: 25432,
subtype: "Local",
title: "General Info Test 2",
type: "Medical Information",
},
];
I want to search the value of attribute ‘Document_ID__c’ from arr1 in arr2 and if it matches ‘176767’ on any element in arr2,
just create a new array and store that element.
For e.g my desired output is
const finalarray = [
{
classification: "Scientific Response",
core_san_localization_translation: ["No"],
core_san_verbal_only: "false",
id: "176767",
major_version_number: "1",
minor_version_number: "0",
name: "Advance Search Doc_General Information",
response_type: ["General"],
size: 70953,
subtype: "Local",
title: "Advance Search Doc_General Information",
type: "Medical Information",
},
];
Please help me on this.