title: Picking 2 random elements from array
body: <p>What is the most efficient way to select 2 unique random elements from an array (ie, make sure the same element is not selected twice).</p>
  
  <p>I have so far:</p>
  
  <pre><code>var elem1;
  var elem2;
  
  elem1 = elemList[Math.ceil(Math.random() * elemList.length)];
  do {
    elem2 = elemList[Math.ceil(Math.random() * elemList.length)];
  } while(elem1 == elem2)
  </code></pre>
  
  <p>But this often hangs my page load.</p>
  
  <p>Any better solution?</p>
  
  <p>Extra question, how do I extend this to <code>n</code> elements</p>