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

189
Vistas
Isolate value that is not contained in one array from another array

I'm trying to find the values in arrayOne that are not contained in each of the two groups in arrayTwo. In the scenario below I would like isolate b and d for group1 and a and b for group2.

   arrayOne = ['a','b','c','d']
    
    arrayTwo = [{
        group1:[['a', 4],['c',8]],
        group2:[['c', 7],['d',11]]
    }]

I've tried several ways up at this point but can't seem to get the order correct. Here is what I currently have:

arrayTwo[0].group1.forEach(e => {
        console.log(e)
        arrayOne.forEach(f => {
            if(e[0] != f) {
                console.log(e[0])
            }
        })
    })

Expected result

b
d
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could use "difference" calculation from How to get the difference between two arrays in JavaScript?

Example:

const arrayOne = ['a','b','c','d']
    
const arrayTwo = [{
    group1:[['a', 4],['c',8]],
    group2:[['c', 7],['d',11]]
}]

const resultForGroup1 = arrayOne.filter(letter => !arrayTwo[0].group1.map(keyValue => keyValue[0]).includes(letter))

document.write(resultForGroup1)

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