Diff Two Arrays using Array.filter and Array.indexof


function diffArray(arr1, arr2) {
  var newArr = arr1.filter(function(word){
    if(arr2.indexOf(word)==-1){
      return word;
    }
    
  });
  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Can someone explain me why am I wrong?

You are currently checking if an element in arr1 is not in arr2. But there might also be elements that are in arr2 which are not in arr1.