I am designing a monopoly style digital game and want a dice rolling button so i tried this:
<button class="bttnrolldice" onclick="diceRoll()">Roll Dice</button><h1 id="rollresults"></h1>
<script>
function diceRoll() {
var die1 = math.ceil(math.random() * 7;
var die2 = math.ceil(math.random() * 7;
document.getElementById("rollresults").innerHTML = (die1 + die2); }
</script>
Whenever I run the code, nothing shows up below the button. Can you give me a hand? (It might have something to do with the variables that equal js code, if so tell me how to fix this.)
Math.ceil(6*(1 - Math.random()));which would include 1 through 6 but exclude 0Math.random()returns a float between 0 (inclusive) and 1 (exclusive) which is why the subtraction fixes the problem