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.