I’m going to write a bit of pseudo code to help with understanding the problem:
//I have 3 arrays
let a = [1];
let b = [2];
let c = [1];
//I want to compare them such that I'm only comparing two at a
//time, and to do this we will start with the first two arrays.
//We will join the two arrays together such that only their
//differences comprise the new array
function compare(array1, array2) {
let a = [];
for (let i = 0; i < lengthOfTheLongestArray; i++) {
if (longestArray[i] isNotIn shorterArray) {
a.push(longestArray[i])
}
}
return a;
}
let d = compare(a, b);
console.log(d) //[1,2]
d = compare(c, d);
console.log(d) //[1, 2]
The code I’ve written above is not the answer, and may not exactly work if extrapolated into real code, but I hope it gives you some ideas.