title: Slimming down nested array Javascript
body: <p>I've been trying to port over the functionality of</p>
  <pre><code>random.sample(range(0, 6), 2)
  </code></pre>
  <p>to javascript from python using this function:</p>
  <pre><code>function randomIntFromInterval(range, n) {
    var sample = [];
    for(var i=0; i&lt;n; i++) {
      sample.push(range.splice(Math.random()*range.length,1));
    }
  
    return sample;
  }
  </code></pre>
  <p>However I am getting this result:</p>
  <pre><code>[[[2], [3]], [[1], [2]], [[6], [1]], [[4], [3]], [[2], [1]], [[6], [2]], [[0], [2]], [[1], [6]], [[1], [3]], [[6], [5]]]`
  </code></pre>
  <p>Instead of something like this:</p>
  <pre><code>[[2, 3], [1, 2], [6, 1], [4, 3], [2, 1], [6, 2], [0, 2], [1, 6], [1, 3], [6, 5]]
  </code></pre>
  <p>Any Tips?</p>
  <p>EDIT: this is the code im using to call the function</p>
  <pre><code>var randomizedOff = []
  while (z &lt; 10){
  randx = randomIntFromInterval([0,1,2,3,4,5,6],2)
    randomizedOff.push(randx)
    z++
  }
  
  </code></pre>