Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
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

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

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());

about 4 years ago · Juan Pablo Isaza Report

0

There are many ways to approach this. One of them could be the indexOf() method.

let str = "test@domain1.com";

str.indexOf('domain1') !== -1 // true

source

about 4 years ago · Juan Pablo Isaza Report

0

You have to map through the second array too like this

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

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

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

console.log(myFunc());
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!