Finding Common Values in Two Arrays
(Last modified: )
function hasCommonElement(arr1, arr2) {
return arr1.some(element => arr2.includes(element));
}
const array1 = [1, 2, 3, 4];
const array2 = [5, 6, 3, 8];
console.log(hasCommonElement(array1, array2)); // Output: true (since 3 is common)
Sources