Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html xmlns = "http://www.w3.org/1999/xhtml">
- <head>
- <title>Roll a Six-Sided Die 6000 Times</title>
- <script type = "text/javascript">
- <!--
- var face, frequency = [ , 0, 0, 0, 0, 0, 0 ];
- // summarize results
- for ( var roll = 1; roll <= 6000; ++roll ) {
- face = Math.floor( 1 + Math.random() * 6 );
- ++frequency[ face ];
- }
- document.writeln( "<table border = \"1\"" +
- "width = \"100%\">" );
- document.writeln( "<thead><th width = \"100\"" +
- " align = \"left\">Face<th align = \"left\">" +
- "Frequency</th></thead><tbody>" );
- for ( face = 1; face < frequency.length; ++face )
- document.writeln( "<tr><td>" + face + "</td><td>" +
- frequency[ face ] + "</td></tr>" );
- document.writeln( "</tbody></table>" );
- // -->
- </script>
- </head>
- <body>
- <p>Click Refresh (or Reload) to run the script again</p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement