Reputation: 7
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.)
Upvotes: 0
Views: 49
Reputation: 511
You are missing closing parenthesis on your Math.ceil
functions
<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>
Upvotes: 1
Reputation: 117
You are missing a right parentheses on line 4 and line 5.
When running your script in Google Chrome, press [F12] and the error will be described on the Console tab.
Upvotes: 1
Reputation: 1467
Inspect element and check browser console for errors.
Upvotes: 0