-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticipants.js
55 lines (46 loc) · 857 Bytes
/
participants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
let people = [
"Olivia",
"Liam",
"Sophia",
"Noah",
"Isabella",
"Ethan",
"Emma",
"Mason",
"Ava",
"Logan",
"Charlotte",
"Lucas",
"Mia",
"Aiden",
"Amelia",
"Jackson",
"Harper",
"Elijah",
"Evelyn",
"James"
];
people = people.sort();
let teams = [
"red",
"blue",
"green",
"yellow"
];
let numberOfAnswersPerQuestion = 4;
let participants = [];
let teamCounters = {};
teams.forEach(team => {
teamCounters[team] = 0;
});
for (let i = 0; i < people.length; i++) {
let person = people[i];
let team = teams[i % teams.length]; // Cycle through the teams
let affinity = teamCounters[team] % numberOfAnswersPerQuestion;
participants.push({
name: person,
team: team,
affinity: affinity
});
teamCounters[team]++;
}