Advertisement
olegsuv

Count NABU votes

May 29th, 2020
1,696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let fileVotes = document.getElementsByTagName('pre')[0].textContent.split('\n').filter(String)
  2.  
  3. function countVotesForCandidate(id) {
  4.     return fileVotes.reduce((accumulator, currentValue) => accumulator + Number(currentValue.split('SEL=')[1].split(' K1')[0].split(',').includes(id.toString())), 0)
  5. }
  6.  
  7. let results = {}
  8. for (i = 1; i <= 34; i++) {
  9.   results[i] = countVotesForCandidate(i)
  10. }
  11. console.table(results)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement