Building and listing top scorers from


Joined
Mar 4, 2022
Messages
1
Reaction score
0
I am trying to build a table of players goalscoring records. I have five arrays:

player, total_goals, goals_1st_half, goals_2nd_half and sorted_goals.


I have created a fiddle with the base arrays in: Fiddle with arrays in and outcomes I don't wish to have the first array sorted - that should always remain as 0 for each array. A couple of players have scored the same number of goals but the player who scored the most in the first-half takes precedence - if they can't be separated it is the lowest index number.

I can sort the array Ok but cannot eliminate, push the zero and work out the arrays where the player has the same goals.
 
Ad

Advertisements

Joined
Mar 11, 2022
Messages
82
Reaction score
8
Zero is equal to false. Which doesn,t matter. Even false can be pushed.
Code:
myArray.push(false);

You can splice zeros too.
Code:
myArray=new Array(1,2,0,5,6);
myArray.splice(2,1);

So what exactly isn't working?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top