title: Relatively pick X values out of Array
body: <p>I'm trying to pick X values relatively out of an Array. For example I'd like to pick 4 values out of the following array:</p>
  
  <pre><code>arr = [1,2,3,4,5,6,7,8,9]
  </code></pre>
  
  <p>what I am doing now is:</p>
  
  <pre><code>var newArr = [];
  var pick = 4;
  var delta = arr.length/pick;
  
  for (i = 0; i &lt; arr.length; i = i + delta) {
      k = Math.floor(i);
      newArr.push(arr[k]);
  };
  
  // then I'm cheating a bit
  newarr[newArr.length-1] = arr[newArr.length-1];
  </code></pre>
  
  <p>My problem is, at some values (I'm using this on longer arrays) the new array is longer than the defined pick variable. This has to do with the delta and the following rounding, who fit an additional value sometimes.</p>
  
  <p>Does anyone know how to do this correctly? The expected result should be one of these:</p>
  
  <pre><code>newArr = [1,3,6,9] || newArr = [1,4,6,9] || newArr = [1,4,7,9]
  </code></pre>