Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Check if second array has any string from first array

I am trying to find if second array has any string from the first one.
Not sure what I am doing wrong

const domainAlertList = ["@domain1", "@tomato2", "@carrot3"];

const search = ["test@domain1.com", "test@tomato2.com"];

const myFunc = () => {
  return search.some((r) => domainAlertList.includes(r));
};

console.log(myFunc());

It returns false instead of true

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

const domainAlertList = ["@domain1", "@tomato2", "@carrot3"];

const search = ["test@domain1.com", "test@tomato2.com"];

const myFunc = () => {
  return domainAlertList.some((r) => {
      return search.some(t => t.includes(r))
  });
};

console.log(myFunc());
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading