Sprint 2 - Introduction to Javascript for RNG Interactive
Lesson for Javascript For RNG
Interactive Dice Rolling & RNG Demo
About Random Number Generation in Dice Games
Dice rolling is a perfect example of random number generation (RNG). In JavaScript, we use Math.random()
to simulate rolling dice:
Math.random()
: Generates a float between 0 (inclusive) and 1 (exclusive)Math.floor(Math.random() * 6) + 1
: Generates integers 1-6 for a standard die- Multiple dice rolls demonstrate independent random events
- Statistics over many rolls show probability distributions
🎲 Standard Dice Roller
Click "Roll Dice!" to start
🎯 Dice Statistics Tracker
Roll multiple times to see probability in action!
Total Rolls: 0
Total Sum: 0
Average Roll: 0
Highest Roll: -
Lowest Roll: -
🔮 Loaded Dice Simulator
Simulate weighted/biased dice to understand how RNG can be manipulated!
Try rolling a loaded die!