title: Javascript: Random number out of 5, no repeat until all have been used
body: <p>I am using the below code to assign a random class (out of five) to each individual image on my page.</p>
  
  <pre><code>$(this).addClass('color-' + (Math.floor(Math.random() * 5) + 1));
  </code></pre>
  
  <p>It's working great but I want to make it so that there are never two of the same class in a row. </p>
  
  <p>Even better would be if there were never two of the same in a row, and it also did not use any class more than once until all 5 had been used... As in, remove each used class from the array until all of them have been used, then start again, not allowing the last of the previous 5 and the first of the next 5 to be the same color.</p>
  
  <p>Hope that makes sense, and thanks in advance for any help.</p>