-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
58 lines (49 loc) · 1.55 KB
/
index.html
File metadata and controls
58 lines (49 loc) · 1.55 KB
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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script>
window.onload = function(){
var students = ["Oksana", "Ross", "Jody", "Virgi", "Brandon", "Levi", "Scott"];
var randomOrder = [];
var countClicks = 0;
function generateOrder (arr){
randomOrder = [];
for (i = arr.length; i > 0; i--){
var count = arr.length;
var randomIndex = Math.floor(Math.random() * (count - 1));
var currentSelected = arr.splice(randomIndex,1);
randomOrder.push(currentSelected);
count --;
}
students = ["Oksana", "Ross", "Jody", "Virgi", "Brandon", "Levi", "Scott"];
return randomOrder;
}
generateOrder(students);
console.log('contents of randomOrder ' + randomOrder);
var printOut = document.getElementById('output');
var buttonStudent = document.getElementById('button');
buttonStudent.onclick = function printOneName(){
if (countClicks < randomOrder.length){
printOut.innerHTML = randomOrder[countClicks];
console.log('this is click # ' + (countClicks + 1) + ' printing: ' + randomOrder[countClicks]);
countClicks ++;
} else {
countClicks = 0;
generateOrder(students);
console.log('new array: ' + randomOrder);
console.log('this is click # ' + (countClicks + 1) + ' printing: ' + randomOrder[countClicks]);
printOut.innerHTML = randomOrder[countClicks];
countClicks ++;
}
}
}
</script>
</head>
<body>
<div class = "content">
<button id="button">Who's Next?</button>
<div id="output">Sample</div>
</div>
</body>
</html>