title: Javascript Rock, Paper, Scissors
body: <p>I followed the tutorial on Javascript on <a href="http://www.codecademy.com" rel="nofollow">http://www.codecademy.com</a> and one part was to create a rock, paper, scissors game. After I finished it I figured I would redesign it a bit to use on my own. So I did this: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
          &lt;script&gt;
          var userChoice = document.getElementById("userChoice").value;
  
          if (userChoice != "rock" &amp;&amp; userChoice != "paper" &amp;&amp; userChoice != "scissors"){
              alert("Your choice was not rock, paper or scissors");
              userChoice = prompt("Do you choose rock, paper or scissors?");
          }
          var computerChoice = Math.random();
          if (computerChoice &lt; 0.34) {
              computerChoice = "rock";
          } else if(computerChoice &lt;= 0.67) {
              computerChoice = "paper";
          } else {
              computerChoice = "scissors";
          }
  
          var compare = function(choice1, choice2) {
              if (choice1 == choice2) {
                  return "The result is a tie!";
              } else if (choice1 == "rock") {
                  if (choice2 == "scissors") {
                      return "Rock wins";
                  } else {
                      return "Paper wins";
                  }
              } else if (choice1 == "paper") {
                  if (choice2 == "rock") {
                      return "Paper wins";
                  } else {
                      return "Scissors wins";
                  }
              } else if (choice1 == "scissors") {
                  if (choice2 == "paper") {
                      return "Scissors win";
                  } else {
                      return "Rock wins";
                  }
              }
          }
  
          function Run() {
              document.getElementById("pcc").innerHTML = "Computer: " + computerChoice;
              document.getElementById("result").innerHTML = compare(userChoice, computerChoice);
          }
      &lt;/script&gt;
      &lt;main&gt;
          &lt;h2&gt;Choose between rock, paper or scissors: &lt;/h2&gt;
          &lt;input id="userChoice"&gt;
          &lt;button onClick="Run()"&gt;Choose&lt;/button&gt;
          &lt;p id="pcc"&gt;&lt;/p&gt;
          &lt;p id="result"&gt;&lt;/p&gt;
      &lt;/main&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But it doesn't work, I get undefined for compare, computerChoice, userChoice and that there isn't anything that becomes stored in value.
  What's wrong? </p>