Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var report = `
- Indu 120
- Joel 18
- Rama 56
- --
- Joel 52
- Indu 14
- Rama 46
- --
- Ido 72
- Joel 14
- Rama 46
- --
- Joel 66
- Indu 6
- Ido 26
- --
- Ido 18
- Rama 34
- Indu 110
- --
- Ido 2
- Joel 6
- Indu 18
- --
- Joel 24
- Ido 30
- Rama 6
- --
- Joel 28
- Ido 6
- Rama 8
- `
- report
- .trim()
- .toLowerCase()
- .split('--')
- .map(match => match
- .trim()
- .split('\n'))
- .reduce((acc, match) => {
- match.forEach(function (playerPoints) {
- !acc[player] && acc[player] = 0
- var [player, points] = playerPoints.split(' ')
- acc[player] += parseInt(points)
- })
- return acc
- }, {})
Add Comment
Please, Sign In to add comment