more cleverer

This commit is contained in:
eneller
2024-07-10 16:20:31 +02:00
parent 8cb49a3efb
commit 1073603350

View File

@@ -11,13 +11,13 @@ function randomizeTeams() {
teams = Array.from({ length: teamCount }, () => []);
playersPerTeam = Math.floor(names.length / teamCount);
namesCopy = [...names]
let nameslen = names.length;
iterator = iter(teams);
for(let i =0; i < names.length; i++){
index = Math.floor(Math.random()* namesCopy.length);
n = namesCopy[index];
namesCopy.splice(index,1);
for(let i =0; i < nameslen; i++){
index = Math.floor(Math.random()* names.length);
n = names[index];
names.splice(index,1);
team = iterator.next().value;
team.push(n);