This (working) code is supposed to return a new array that consists of elements of both arrays that were not marked as duplicates (find duplicates in both arrays, remove such elements from both arrays and create an array from the leftovers, if any)
Is there a way to simplify this function?
function diff(arr1, arr2) {
var arr1_filtered, arr2_filtered;
arr1_filtered = arr1.filter(function (v) {
return arr2.indexOf(v) == -1;
});
arr2_filtered = arr2.filter(function (v) {
return arr1.indexOf(v) == -1;
});
return arr1_filtered.concat(arr2_filtered);
}