About Leader Board in Javascript (Array) Help Me Please
- by raulcorrales
Hi to all. I need help with a score table for my game.
-1- I have 4 variables:
var Player1Score= 44;
var Player2Score= 12;
var Player3Score= 45;
var Player4Score= 26;
--2-- i make a Array:
var MyArray=[Player1Score,Player2Score,Player3Score,Player4Score];
--3-- sort the array:
MyArray.Sort();
--4-- Print:
----------HIGHSCORES----------
45
44
26
12
MY QUESTION IS: HOW I CAN PRINT THE NAME OF THE PLAYERS IN ORDER¿?
LIKE THIS:
----------HIGHSCORES----------
PLAYER 3 45
PLAYER 1 44
PLAYER 4 26
PLAYER 2 12
THANKS IN ADVANCE. GREETINGS