Pairwise (Wrong test case)

Tell us what’s happening:

Your code so far

function pairwise(arr, arg) {

  return Object.entries(arr.reduce(function(pairs,curr,id,self){
   var other = self.indexOf(arg-curr,id+1);
   if(other != -1) {
     var pair = curr<arg-curr?curr:arg - curr;
     if(pairs.hasOwnProperty(pair)){
       pairs[pair] = Math.min(pairs[pair],id+other);
     } else {
       pairs[pair] = id+other;
     }
   }
   return pairs;
 },{})).reduce(function(sum,val){
   return sum + val[1];
 },0);
  
}

pairwise([1,4,2,3,0,5], 7);

Your browser information:
Google Chrome
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/pairwise

The testcase 4 is wrong.

Given: pairwise([0, 0, 0, 0, 1, 1], 1) should return 10.
Actually it should be pairwise([0, 0, 0, 0, 1, 1], 1) should return 4.