title: How to pick random element in an array AVOIDING (EXCEPT if it's) a certain value?
body: <p>For example, when users are connecting to this application they are given a userid var, then it's inserted into the array. So, i'm using</p>
  
  <p><code>chosenUser = usersOnlineArray[Math.round((Math.random()*usersOnlineArray.length))];</code></p>
  
  <p>to pick another random user. But i need to make sure it doesn't pick the userID they personally were assigned so they don't end up getting themselves.</p>
  
  <p>how would i use that code but tell it to "remember, make sure you don't pick userid"</p>
  
  <p>maybe I could do something like </p>
  
  <pre><code>chosenUser = usersOnlineArray[Math.round((Math.random()*usersOnlineArray.length))];
  
      if (chosenUser = userid)
      {
          chosenUser = usersOnlineArray[Math.round((Math.random()*usersOnlineArray.length))];
      } else
      {
      //next part of mycode
      }
  </code></pre>
  
  <p>Maybe that should be a <code>while (chosenUser = userid)</code> incase it gets it twice...</p>
  
  <p>But, i'm thinking i could skip all that if there is a efficent way just to make sure it doesn't pick it in the first place.</p>
  
  <p>Sorry, i'm not quite sure how I should have phrased the question or if there is a term i'm unaware of to refer to what i'm trying to do. </p>