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

140
Views
Plain Javascript: How to check if 1) array A has any elements of array B and 2) if array A has any elements array B doesn't have

The things I want to check:

  1. Does array A have any elements of array B?
  2. Does array A have any elements that array B doesn't have?

Scenario 1:

Array A = [1, 2]

Array B = [1, 2, 3, 4]

  1. Yes
  2. No

-> Give the answer true

Scenario 2:

Array A = [1, 2, 5]

Array B = [1, 2, 3, 4]

  1. Yes
  2. Yes

-> Give answer false

Scenario 3:

Array A = [5]

Array B = [1, 2, 3, 4]

  1. No
  2. Yes

-> Give answer false

I understand it may seem/be cocky to type basically a request for some code and expect someone to write it up, but I've spent 15 hours trying to either learn enough about arrays to do it myself, and also tried different solutions that were kind of close to what I asked on stackoverflow and tweaking them, but I just can't make a system that works by answering question 1) and 2) the way I want

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

0

  1. A.some((x) => B.includes(x))

  2. A.some((x) => !B.includes(x))

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!