Generating a strings of random characters from an array and enabling repetition of randomly generated numbers
<p>Good evening everyone,</p>

<p>I am trying to generate a string of 8 characters, which are randomly chosen from an array. This is what I am using:</p>

<pre><code>var myArrayPismo = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; 

while(myArrayPismo.length &lt; 9){
    var randomletter = Math.ceil(Math.random()*myArrayPismo.length)
    if(myArrayPismo.indexOf(randomletter) &gt; -1) continue;
    myArrayPismo[myArrayPismo.length] = randomletter;
}
</code></pre>

<p>Which just prints out all of the letters, for some reason.</p>

<p>And this is my number generating function:</p>

<pre><code>var kodCisla = [];
while(kodCisla.length &lt; 9){
    var randomnumber = Math.ceil(Math.random()*9)
    if(kodCisla.indexOf(randomnumber) &gt; -1) continue;
    kodCisla[kodCisla.length] = randomnumber;
}
</code></pre>

<p>Which is working fine. Except I want it to be able to generate 2 or more same numbers, not just different each time.</p>

<p>My goal is to get a random string of letters like this: <code>KODlkSmQW</code>
and a random string of numbers that can also repeat like this: <code>887562327</code></p>

<p>Any help on either of these problems would be appreciated.</p>