Skip to content

Instantly share code, notes, and snippets.

@g1stavo
Created November 29, 2018 17:52
Show Gist options
  • Save g1stavo/9f71c5e11c29cd3666efc6ee4a6705b7 to your computer and use it in GitHub Desktop.
Save g1stavo/9f71c5e11c29cd3666efc6ee4a6705b7 to your computer and use it in GitHub Desktop.
$ groups=X min=X node randomizer.js
const env_groups = process.env.groups;
const env_min = process.env.min;
let participants = [
'Juliana',
'Christian',
'Gleice',
'Gustavo',
'Denise',
'Eduardo',
'Fernanda',
'João',
'Gilmar',
'Lucas'
];
let groups = [];
for (let i = 0; i < env_groups; i++) {
let temp = [];
for (let j = 0; j < env_min; j++) {
let random = participants[Math.floor(Math.random() * participants.length)];
temp.push(random);
participants = participants.filter(item => {
return item !== random;
});
}
groups.push(temp);
}
groups.forEach((item, index) => {
console.log(item);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment