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

164
Vistas
Why is my detecting object function not working?

I'm trying to create an array comparer for two arrays of objects that can be fetched. I don't know what I did wrong at all but for some reason, whenever I run the obj array comparer, instead of giving me the proper results it gives me a bunch of empty brackets (the amount of the arrays) instead of giving me the differences. Like if I had an object array of 5 different items in a and in b there were 4, even though there is clearly a difference it would just give me 4 empty brackets. This is what I have (however I changed some of the stuff but it is still the core code just different fetches):

function differenceDetector(arrayA, arrayB, test) {
test = test || ((arrA, arrB) => arrA === arrB); 
return arrayA.filter(arrA => !arrayB.find(arrB => test(arrA,arrB)));
}

let fetchA = await fetch('https://a/data');
  let fetchB = await fetch('https://b/data');
  let arrA = await fetchA.json();
  let arrB = await fetchB.json();     

console.log(differenceDetector(arrA, arrB));
for(let count=0; count<arrB.length; count++){
let idA = [{id: arrA}];
let idB = [{id: arrB}];
const detectTest = (idA, idB) => idA[count] === idB[count];                                               
console.log(differenceDetector(idA, idB, detectTest));}}                                             
x();                                                                                            

If someone could help me figure out what I did wrong that would be amazing. Thanks.

about 4 years ago · Juan Pablo Isaza
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