About Leader Board in Javascript (Array) Help Me Please
Posted
by
raulcorrales
on Programmers
See other posts from Programmers
or by raulcorrales
Published on 2011-03-19T06:12:17Z
Indexed on
2011/03/19
8:17 UTC
Read the original article
Hit count: 180
JavaScript
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
© Programmers or respective owner