-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroll-dice-v2-array.html
More file actions
37 lines (26 loc) · 1018 Bytes
/
roll-dice-v2-array.html
File metadata and controls
37 lines (26 loc) · 1018 Bytes
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
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Roll a Six-Sided Die 60000 times</title>
<script type="text/javascript">
var frequency = [,0,0,0,0,0,0,];
var face;
for (var roll = 1; roll <= 60000; roll++) {
face = Math.floor(Math.random() * 6 + 1);
++frequency[face];
// alert(face);
}// end for loop
//display result in a table
document.writeln("<table border = \"2\">");
document.writeln("<thead><tr><th>Face</th>" + "<th>Frequency </th> </tr> </thead>");
document.writeln("</tbody>");
for(var face = 1; face<frequency.length; face++) {
document.writeln("</tr><td>" + face + "</td><td>" + frequency[face] + "</td></tr>");
}
document.writeln("</tbody></table>");
</script>
</head>
<body>
</body>
</html>