Simple Dice Game: Roll the Highest Number - HTML Game
Simple Dice Game!
<p>Let's play a game of dice! The goal is to roll the highest number.</p>
<div>
<button onclick='rollDice()'>Roll Dice</button>
<p id='dice-result'></p>
</div>
<script>
function rollDice() {
let diceResult = Math.floor(Math.random() * 6) + 1;
document.getElementById('dice-result').innerHTML = 'You rolled a ' + diceResult;
}
</script>
原文地址: https://www.cveoy.top/t/topic/lmlV 著作权归作者所有。请勿转载和采集!