Compare Arrays - Big O sample

Run Settings
LanguageJavaScript
Language Version
Run Command
const array1=["test","QA","INT","Server","project"]; const array2=["testing","test","qa","Server",8,9]; function CreateObject(array1) { let obj={}; for(let i=0;i<array1.length;i++) { if(!obj[array1[i]]) { const item=array1[i]; obj[array1[i]]= true; } } let matchCount=0; for(let j=0;j<array2.length;j++) { if(obj[array2[j]]) { matchCount=matchCount+1; console.log("Match found"+" and matched value is : "+ array2[j]); } else { console.log("No match found"); } } console.log("____________________________________________________________________") console.log("____________________________________________________________________") console.log("Total no of objects that matched are : "+ matchCount); } CreateObject(array1);
Editor Settings
Theme
Key bindings
Full width
Lines