title: jQuery: Get random item from array and assign class once
body: <p>I'm relatively new in jQuery, or any script for that matter. I tried several approaches, but can't seem to get the effect i want.</p>
  <p>What i want is:</p>
  <ul>
  <li>Get the list of elements, divs in this case</li>
  <li>Assign a unique class or ID to 5 of them</li>
  </ul>
  <p>I have managed to assign the unique class, but this involves running a new function 5 times. And sometimes the same div gets multiple classes.</p>
  <p>My code so far:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var places2beObj = $('#blokken_clubinfo &gt; div');
  
  $.makeArray(places2beObj);
  
  
  console.log(places2beObj);
  
  function randomPlace2be1() {
    var randomPlace = places2beObj[Math.floor(Math.random() * places2beObj.length)];
    $(randomPlace).addClass("random1", function() {
      places2beObj.splice(randomPlace, 1);
    });
  }
  
  function randomPlace2be2() {
    var randomPlace = places2beObj[Math.floor(Math.random() * places2beObj.length)];
    $(randomPlace).addClass("random2", function() {
      places2beObj.splice(randomPlace, 1);
    });
  }
  
  randomPlace2be1()
  randomPlace2be2()</code></pre>
  </div>
  </div>
  </p>