Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript win counter for dice game
    primarykey
    data
    text
    <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; div.dice { float:left; width:32px; background:#F5F5F5; border:#999 1px solid; padding:10px; font-size:24px; text-align:center; margin:5px; } &lt;/style&gt; &lt;script&gt; function rollDice() { var die1 = document.getElementById("die1"); var die2 = document.getElementById("die2"); var status = document.getElementById("status"); var d1 = Math.floor(Math.random() * 6) + 1; var d2 = Math.floor(Math.random() * 6) + 1; var wins = documentgetElementById("doubles"); var diceTotal = d1 + d2; die1.innerHTML = d1; die2.innerHTML = d2; status.innerHTML = "You rolled " + diceTotal + "."; if (d1 == d2) { status.innerHTML += " DOUBLES! You get a free turn!!"; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="die1" class="dice"&gt;0&lt;/div&gt; &lt;div id="die2" class="dice"&gt;0&lt;/div&gt; &lt;button onclick="rollDice()"&gt;Roll Dice&lt;/button&gt; &lt;h2 id="status" style="clear:left;"&gt;&lt;/h2&gt; &lt;br&gt;Wins: &lt;h5 id="doubles" style="clear:left;"&gt;&lt;/h5&gt; &lt;br&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I want to have it so the Wins is updated every time they roll doubles I still noob at this i was thinking it would be a simple line of code added after the <code>status.innerHTML += " DOUBLES! You get a free turn!!"; doubles.innerHTML =+ Wins; put var wins = document.getElementById("doubles");</code> ??? i know im doing something wrong any help would be awesome! Sincerely LM</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload