title: javascript generating random characters
body: <p>I am trying to program a password generator. However, I find that my code is unreliable. I want each run of my function to return 20 random characters. This works most times, however if I spam the function enough times then I sometimes get a result that's below my criteria (eg: 2 strings, none, etc). </p>
  
  <pre><code>var longth = 20,
  allc = "!@#$%^&amp;*()_+~`|}{[]\:;?&gt;&lt;,./-=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  passgen = '';
    for (var i = 0; i &lt; longth; i++) {
      passgen += allc.charAt(Math.floor(Math.random() * allc.length));
    }
  </code></pre>
  
  <p>Not sure if the problem is with logic in my code, or if there's a break in one of the characters in my <code>allc</code> variable that's causing problems. Maybe I'm not expressing the variable correctly. </p>