Looking for help on how to rank 3 players based on their scores using arrays. I've hit a roadblock and need guidance!
Here's a brief example:
Player 1 : Taylor
Score Taylor : 15
Player 2 : Jordan
Score Jordan : 20
Player 3 : Alex
Score Alex : 18
After ranking, we should have:
The first => Jordan with 20 scores
The second => Alex with 18 scores
The third => Taylor with 15 scores
Below is the code snippet I'm currently working on:
function main() {
var players = new Array();
var scores = new Array();
for(i = 0; i<3; i++) {
players[i] = prompt("Player " + (i+1) + " : ");
scores[i] = prompt("Score " + (players[i]) + " : ");
}
}
Appreciate any assistance in advance!