Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
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 Respuestas
Responde la pregunta

0

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

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda