Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda