title: How to add score to javascript game
body: <p>I was just wondering how to add score to my JavaScript game as I am unsure thanks :)
  I am trying to make a score so if you win it adds a point and after ten goes it stops and shows you your score out of ten.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
    function myFunction() {
      var textfield1 = document.getElementById("textfield1");
      var input = textfield1.value;
      var input = input.toLowerCase();
      var cpu = Math.floor((Math.random() * 3) + 1);
  
      if (input == 1 || input == 2 || input == 3) { 
      } else if (input == "rock") {
        var input = 1;
      } else if (input == "paper") {
        var input = 2;
      } else if (input == "scissors") {
        var input = 3;
      } else {
        alert("Invalid Input!"); 
        return;
      }
  
      if (input == 1 &amp;&amp; cpu == 3) {
        alert("You Win! Rock beats scissors!");
      } else if(input == 2 &amp;&amp; cpu == 1) {
        alert("You Win! Paper Over Rock!");
      } else if(input == 3 &amp;&amp; cpu == 2) {
        alert("You Win! Scissors Cuts Paper");
      } else if (input == cpu) {
        alert("Its a tie!");
      } else {
        alert("You lose!");
      }
    }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body align="center"&gt;
  &lt;img           src="https://31.media.tumblr.com/1bb16c331ba5cc303c0f370e9927c740/tumblr_inline_n2yc8uRLei1r6abro.jpg"&gt;
  &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;h1&gt;&lt;font size="10pt" face="Verdana" color="red"&gt;
  Scissors Paper Rock Game!
  
  
  
  &lt;/h1&gt;
  &lt;input type="text" name="input1" id="textfield1"&gt;
  &lt;/input&gt;&lt;br&gt;
  &lt;input type="button" name="button1" onclick="myFunction()" value="Go"&gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="number" name="myScore"value="0" readonly&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is my fiddle: <a href="http://jsfiddle.net/6Phv9/" rel="nofollow">http://jsfiddle.net/6Phv9/</a></p>