SOURCE

const teamsTemp = [
  {name: 'a', scores: [1, 2, 3]},
  {name: 'b', scores: [4, 4, 6]},
  {name: 'c', scores: [6, 9, 9]},
  {name: 'd', scores: [0, 3, 9]},
  {name: 'e', scores: [9, 5, 8]},
  {name: 'f', scores: [8, 7, 4]}
]
function maxScoresTeam(teams) {
  const rst = []
  const rstLength = teams[0].scores.length
  for (let i = 0; i < teams.length; i++) {
    const currentTeam = teams[i]
    for (let j = 0; j < rstLength; j++) {
      if (!rst[j]) {
        rst[j] = [
          {name: '', score: 0}
        ]
      }
      if (currentTeam.scores[j] === rst[j][0].score) {
        rst[j].push(
          {name: currentTeam.name, score: currentTeam.scores[j]}
        )
      }
      if (currentTeam.scores[j] > rst[j][0].score) {
        rst[j] = [
          {name: currentTeam.name, score: currentTeam.scores[j]}
        ]
      }
    }
  }

  return rst.map(
    function(rstItem) {
      return rstItem.map(
        function(item) {
          return item.name
        }
      )
    }
  )
}

console.log(maxScoresTeam(teamsTemp))
console 命令行工具 X clear

                    
>
console