roll
2 years ago in HTML
<html>
<body>
<button onclick="generateDiceRoll()">Roll the Dice</button>
<script>
function generateDiceRoll() {
// Generate a random number between 1 and 6 (inclusive) for each dice roll
let dice1 = Math.floor(Math.random() * 6) + 1;
let dice2 = Math.floor(Math.random() * 6) + 1;
let dice3 = Math.floor(Math.random() * 6) + 1;
let dice4 = Math.floor(Math.random() * 6) + 1;
// Display the result of the dice rolls
alert(`Dice 1: ${dice1}\nDice 2: ${dice2}\nDice 3: ${dice3}\nDice 4: ${dice4}`);
}
</script>
</body>
</html>