Untitled

Run Settings
LanguageJavaScript
Language Version
Run Command
//Program to find common elements in the both arrays. If atleast one common element is there return true else return false let arr1=['a','b','c','d','a','b','c','d']; let arr2=['x','y','z']; let map={}; let areThese=theseSetsHaveCommpnElements(arr1,arr2); console.log(areThese); function theseSetsHaveCommpnElements(arr1,arr2){ for(let i=0;i<arr1.length;i++){ if(!map[arr1[i]]){ const item=arr1[i]; map[item]=true; } } //con{sole.log(map); for(let i=0;i<arr2.length;i++){ if(map[arr2[i]]){ return true } } return false; }
Editor Settings
Theme
Key bindings
Full width
Lines