Advertisement
jargon

haveCommonEntry

Nov 3rd, 2024
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function haveCommonEntry(arr1, arr2) {
  2.    
  3.     let tolerance = 8;
  4.    
  5.     if ( arr1.length < tolerance || arr2.length < tolerance ) {
  6.         return arr1.some(item => arr2.includes(item));
  7.     } else {
  8.         const set1 = new Set(arr1); return arr2.some(v => set1.has(v));
  9.         return set1;
  10.     }
  11. }
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement