Best way to build a random team generator

  arrays, javascript

I’m currently learning frontend development and in my quest for developing my skills i’ve challenged myself with building a random team generator.

Bit of back story; Me and some of my friends regularly hold a COD Warzone tournament inside of our group (12 of us) we randomly select players for each team. However, I want to automate this based on KD ratio (kills/death) with the highest KDs being spilt into 1 of 4 teams. Then I plan to have the same work for Mid and Lower KDs. This way all the teams would have an equal proportion of KD ratios.

Now, this feels quite ambitious for someone who is still very new to JS and I know that I need either a nested array or object to house the name/KD data and then build a function to iterate through each array, but for the life of me I can’t figure it out.

What would be the best way of housing the player data?

A nested array e.g:

var team = [ [Name, KD], [Name, KD], [Name, KD], [Name, KD]];

or an object?

var users = { Name:KD, Name:KD, Name:KD,Name:KD,};

And then building a function that will run through each nested array and based on their KD assign them to a random team variable?

Source: Ask Javascript Questions