title: How to Generate a random number of fixed length using JavaScript?
body: <p>I'm trying to generate a random number that must have a fixed length of exactly 6 digits.</p>
  
  <p>I don't know if JavaScript has given below would ever create a number less than 6 digits?</p>
  
  <pre><code>Math.floor((Math.random()*1000000)+1);
  </code></pre>
  
  <p>I found this question and answer on StackOverflow <a href="https://stackoverflow.com/questions/8476152/random-number-with-fixed-length">here</a>.  But, it's unclear.</p>
  
  <p>EDIT:   I ran the above code a bunch of times, and Yes, it frequently creates numbers less than 6 digits. Is there a quick/fast way to make sure it's always exactly 6 digits?</p>