let data = [{
    name: 'foo',
    score: 10,
  },
  {
    name: 'bar',
    score: 20
  },
  {
    name: 'foo',
    score: 15,
  },
];

let hs = data.reduce((b, a) => {
    let i = b.findIndex(e => e.name === a.name)
    if (i > -1) b[i].score = Math.max(b[i].score, a.score)
    else b.push(a)
    return b;
  }, []);
console.log(hs)

Last Updated:
Contributors: pengrengui