title: limiting the length of output of a random string generator
body: <p>My random generator makes names predominately to the large side. From what I read that can be a factor if you use <code>.round</code>, <code>.ceil</code> or <code>.floor</code>. It also it supposed to make a name no smaller than 3 and no larger than 13.</p>
  
  <p>After adding the title to the name, some of the names were 2 and 14 and such, so I modified it again. Am I going the wrong way about this?</p>
  
  <pre><code>var nameLength = Math.floor(Math.random() * (13 - 3) + 3); /* min 3 max 13*/
  var compareLetter = 0;
  var randomLetter = "";
  var randomName = "";
  var capitolLetter = "";
  var checkLetter = 0;
  var nameTitle = "XXX"; /* titles add _ between title and name*/
  var nameLetters = [
      ["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", "e", "i", "o", "u"],
      ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]
  ];
  if (nameTitle !== "") { /* my attempt to subtract title length +1 from name length if over 13*/
      nameLength = nameLength + (nameTitle.length + 1);
      if (nameLength &gt; 13) {
          nameLength = nameLength - (nameLength - 13);
      }
  }
  for (i = 0; i &lt; nameLength; i++) {
      randomLetter = nameLetters[compareLetter][Math.floor(Math.random() * nameLetters[compareLetter].length)];
      checkLetter = nameLetters[1].indexOf(randomLetter);
      if (checkLetter &gt; -1) { /* my version of keeping consanants and vowels from stacking up */
          compareLetter = 2;
      } else {
          compareLetter = 1;
      }
      if (randomName.length &lt; 1) { /* my version to keep first letter capitolized*/
          capitolLetter = randomLetter.toUpperCase();
          randomName = randomName + capitolLetter;
      } else {
          randomName = randomName + randomLetter;
      }
  }
  if (nameTitle !== "") {
      alert(nameTitle + "_" + randomName);
  } else {
      alert(randomName);
  }
  alert(nameLength);
  alert(randomName.length);
  </code></pre>
  
  <p>Any guidance would be appreciated.</p>