- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroll-dice-v2-array.html
More file actions
Latest commit
37 lines (26 loc) · 1018 Bytes
/
Copy pathroll-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>
<htmllang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<metacharset="utf-8" />
<title>Roll a Six-Sided Die 60000 times</title>
<scripttype="text/javascript">
varfrequency=[,0,0,0,0,0,0,];
varface;
for(varroll=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(varface=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>