Last active
April 25, 2018 17:26
-
-
Save juanique/5f9b71a2c20117e1358d50b464c88d67 to your computer and use it in GitHub Desktop.
Most played heroes in recent games
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var heroesCount = {}; | |
| var rows = document.querySelector('.rgMasterTable ').children[2].children; | |
| for (let i = 0; i < rows.length; i++) { | |
| row = rows[i]; | |
| let heroName = row.children[4].innerText; | |
| heroesCount[heroName] = heroesCount[heroName] || 0; | |
| heroesCount[heroName] += 1; | |
| } | |
| var heroesArray = [] | |
| for (hero in heroesCount) { | |
| heroesArray.push({"name": hero, "count": heroesCount[hero]}); | |
| } | |
| heroesArray.sort((x, y) => {return y.count - x.count}); | |
| heroesArray.forEach(h => { | |
| console.log(h.name + "\t" + h.count) ; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment