title: Storing random numbers in an array of length 25
body: <p>I am trying to create an array of length 25, and generate a random number every 1 second and add it to this array.  </p>
  
  <p>However, I want that once the length of array is reached, the old values start being replaced with the newly random generated values.  This is where I have arrived so far, I am not that familiar with javascript, so any improvements are welcome:</p>
  
  <pre><code>var arr = [];
  arr.length = 25;
  
  function generate() {
     arr.push(Math.floor(Math.random() * 6) + 1);
  }
  setInterval(generate, 1000);
  </code></pre>
  
  <p>Can anyone tell me how I can enforce the length of the array to 25 and once this length is reached start replacing old values with new ones?  I need that the new values are always added to the end of the array as these will be used to generate a graph.</p>
  
  <p>Thanks</p>