I'm trying to solve this issue:
I have an array like that (I cannot change the way it is structured):
[
[{rivals: ['player1','player2'], winner: "player1"}],
[{rivals: ['player1','player3'], winner: "none"}],
[{rivals: ['player2','player3'], winner: "player3"}],
[{rivals: ['player1','player4'], winner: "none"}]
]
What I'm trying to get is: count every player's points, ie if a player (f.ex player1) wins the player counter is increasing by 3points, if none of rivals win then both counters will be increased by 1point. So at the end I would like to get something like (basing on the example above):
const player1Counter = 5;
const player2Counter = 0;
const player3Counter = 4;
const player4Counter = 1;
Thank you for helping!