x = [1, 2,3, 5]; y = [1, [2], [3, [[4]]],[5,6]]));
I am currently facing a challenge in finding the difference between these two arrays.
function findArrayDifference(arr1, arr2) {
var tempArr = [], difference = [];
for (var i = 0; i < arr1.length; i++) {
tempArr[arr1[i]] = true;
}
for (var i = 0; i < arr2.length; i++) {
if (tempArr[arr2[i]]) {
delete tempArr[arr2[i]];
} else {
tempArr[arr2[i]] = true;
}
}
for (var key in tempArr) {
difference.push(key);
}
return difference;
};
The above code snippet is what I attempted at first but it did not work as expected due to the presence of arrays within arrays. Can anyone provide some guidance on how to tackle this issue?