title: How to generate random words in JavaScript?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong> <br/>
    <a href="https://stackoverflow.com/questions/4550505/getting-random-value-from-an-array">Getting a random value from a JavaScript array</a></p>
  </blockquote>
  
  
  
  <p>OK, so I have three variables here, each being rock, paper or scissors. Using JavaScript, how can I generate one of those words randomly?</p>
  
  <p>So far it's like so:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;body&gt;
          &lt;button type="button" onclick="myFunction()"&gt; Click me&lt;/button&gt;
  
          &lt;script&gt;
              function myFunction()
              {
                  var c="Rock";
                  var d="Paper";
                  var e="Scissors";
              }
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Then I'll have a variable called K, which will be the random word out of rock paper or scissors. So it'll be like so:</p>
  
  <pre><code>alert("The computer chose: " + k);
  </code></pre>
  
  <p>So how can I make JavaScript select randomly between the three variables, <code>c</code>, <code>d</code> and <code>e</code>?</p>