-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
67 lines (62 loc) · 2.38 KB
/
script.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
56
57
58
59
60
61
62
63
64
65
66
67
const bt=document.getElementById('btn');
let res=document.getElementById('resetButton');
bt.addEventListener("click",function(){
let t=document.getElementById('total').value;
let m=document.getElementById('mpt').value;
let para;
let rad;
let team=t/m;
let array=[];
let store=[];
array[0]=Math.floor(Math.random( )*t)+1;
let at=t-1;
//Random and unique number in array
while(at!=0)
{
rad=Math.floor(Math.random()*t)+1;
if(array.includes(rad)==false)
{
array.push(rad);
}
else
{
at=at+1;
}
at=at-1;
}
//Teams assign
let count=0;
let index=0;
let times=0;
let ct=0;
for(let i=0;i<team;i++)
{
ct=i+1;
para=document.createElement('p');
while(times<m)
{
store[index++]=array[count++];
times+=1;
}
para.innerText="Team "+ct+": "+store;
document.getElementById('output').appendChild(para);
times=0;
index=0;
while(store==" ")
{
store.pop();
}
}
res.style.visibility="visible";
})
const resetButton = document.getElementById('resetButton');
let total=document.getElementById('total').value;
let mem=document.getElementById('mpt').value;
resetButton.addEventListener('click', () => {
document.getElementById('output').innerHTML = '';
let t=document.getElementById('total').value=null;
let m=document.getElementById('mpt').value=null;
total.value='';
mem.value='';
res.style.visibility="hidden";
});