Check if an array contains any element of another array in JavaScript

arr1 = ['AuditOfficer','ExecutiveOperations','BranchManager','Employee','HO','Vendor','account'];
arr2 = ['Vendor','account']; 


let found = arr1.some(r=> arr2.indexOf(r) >= 0);

console.log(found);

No comments:

Post a Comment