Skip to main content
100%

Dice Library

✓ Published0🌍 Public
Aangusgrant
Last edited Feb 19, 2023
Created on Feb 19, 2023

This example presents a "Dice Library" as a plain HTML page with a title and minimal styling, but all interaction occurs in the browser console. The code defines seven dice-rolling functions—`d2`, `d4`, `d6`, `d8`, `d10`, `d12`, and `d20`—each returning a random integer within its respective range. Each function uses a Fisher–Yates shuffle algorithm to randomly reorder an array of sequential numbers and then extracts the first element, adding one to yield a 1-based result. The functions are exposed via a module pattern, allowing console users to call them directly, such as `roll.d20()`, to simulate dice rolls without any visual output.

AI-generated description

Similar vizzes