title: Math.round(Math.random()) combination seems to be generating too many 0's in my javascript programme
body: <p>I am trying to make a really simple script to generate a 2d array in which every nth array does not contain it's own index as an element but contains a random amount of other randomised index values as their elements and can not be empty. The following is a little code I wrote to attempt to achieve this:</p>
  
  <pre><code>totElList = []
  numEls = 1000
  
  for (i=0;i&lt;numEls;i++) {
      totElList[i] = []
      for (j=0;j&lt;numEls;j++) {
          totElList[i][j] = j
      }
  }
  
  for (i in totElList) {
      totsplice = Math.round(Math.random()*(numEls-1))
      totElList[i].splice(i,1)
      for (j=0;j&lt;totsplice;j++) {
          rand = Math.round(Math.random()*totElList[i].length)
          while (typeof(totElList[i][rand]) === undefined) {rand = Math.round(Math.random()*totElList[i].length)}
          totElList[i].splice(rand,1)
      }
  }
  </code></pre>
  
  <p>The problem is when I run this the totElList array seems to contain more 0's than any other number even though I assumed elements would be removed at random. I did a test to confirm this. The amount of 0's is always the maximum out of all possible values for a given numEls. I am guessing this is something to do with the workings of Math.random() and Math.round() but I am unsure. Could somebody please give me some insight? Thank you.</p>