I wanted to know how I can return an array of names currently on the leaderboard.
This is the code I have:
function top10(maximumResults) { //store the leaderboard elements //check if leaderboard is less than 10 //loop through leaderboard //return var output2 = document.getElementById("top10").getElementsByTagName("li"); var output = ""; for(var i = 0; i < output2.length; i++) { if(maximumResults.length < 10) { output[i] += output2[i].id; } } return output; }
<div id=leaderboard class=panel> <h1>Leaderboard</h1> <ol id=top10> <li>test</li> <li>aaadad</li> <li>dfghfdh</li> <li>dfghdfhg</li> <li>dfghfdh</li> </ol> </div>