I am trying to compare 2 arrays and return a new array with any items only found in one of the two given arrays. So here is what I got:
function diffArray(arr1, arr2) {
  var newArr = [];
  var max;
  var test;
  (arr1.length > arr2.length) ? (max = arr1, test = arr2) : (max = arr2, test = arr1);
  for (let i = 0; i < test.length; i++) {
    if (max.indexOf(test[i]) === -1) {
      newArr.push(test[i])
    }
  }
  return newArr;
}
console.log(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]));However, when I run it, newArr returns an empty array. Can someone point out the error?
 
     
     
    