Extract higher value of pair from JavaScript array
Rewrite
Here's a functional approach, with notes inline as comments.
Note that the internal variables are all essentially simple &quot;helper&quot; functions or calculations, which allow us to write the entire algorithm that you're seeking as a single statement (the final return).
The basic idea is to first group together the pairs of &quot;twin&quot; elements.  Once we have that, we just go through the pairs and select the one with the highest weight.
function bestOfPairs(input) {
  var pairId   = elm    =&gt; elm.id.split('-').sort().join(''),        // creates an id that's the same for both elements of a &quot;pair&quot;
      byWeight = (a, b) =&gt; parseInt(b.weight) - parseInt(a.weight);  // reverse sort by weight: best candidate will be first in array
      grouped  = input.reduce((m, x) =&gt;
        (m[pairId(x)] = (m[pairId(x)] || []).concat(x)) &amp;&amp; m         // groups together elements as pairs, based on their id
      , {});

  return Object.keys(grouped).map(id =&gt; {                            // each &quot;id&quot; here is the &quot;pairs&quot; id, that is, the id being used to create the groups
    var sorted  = grouped[id].sort(byWeight),
        invalid = sorted[1] == undefined || 
                  sorted[0].weight == sorted[1].weight;
    return invalid ? null : sorted[0];                               // returns the element with higher weight, or null if they're equal, or there's only one
  })
  .filter(x =&gt; x !== null);                                          // this removes elments with the same weight
}

Output
[ { id: 'A-B', x: '1', y: '0', weight: '100' },
  { id: 'A-C', x: '2', y: '0', weight: '77' },
  { id: 'A-D', x: '3', y: '0', weight: '95' },
  { id: 'B-C', x: '1', y: '2', weight: '3' },
  { id: 'D-F', x: '5', y: '3', weight: '18' } ]

Finally, note that I'm using ES6 syntax, which is supported by modern browsers, but if you needed support for older browsers you'd need to transpile it using Babel.