title: Attempt to filter array items that were recently used
body: <pre><code>Array.prototype.spil = function (x,max) {
      if (this.length===max) {
          this.shift();
          this.push(x);
      } else {
          this.push(x);
      }
      return this;
  }
  
  var heard = [0],
      freash = [];
  
  $('#speak').bind('touchstart', function() {
      var sounds = [
          1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
          21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
      ];
      var temp = sounds;
      for (var i=0; i&lt;heard.length; i++) {
          temp.splice(temp.indexOf(heard[i]), 1);
      }
      freash = temp;
      var say = Math.floor(Math.random() * freash.length+1) + 1;
      heard.spil(say,10);
      say = document.getElementById('c'+say); // audio element
      // use the sound...
  });
  </code></pre>
  
  <p>My attempt to make the sound that plays 'an un-recent one' is not working! I want to make the last sound that played not play again for 10 button clicks.</p>
  
  <p><code>heard</code> is the array of sounds that you have already heard, this has a <code>Array.spil</code> function which will fill the array via <code>push</code> until it reaches its max length of ten when it will <code>shift</code> then <code>push</code> instead.</p>
  
  <p><code>freash</code> is the array of sounds with no members of the <code>heard</code> array present.</p>
  
  <p>You can see that <code>heard</code> and <code>freash</code> are declared outside of the click (<code>touchstart</code>) scope.</p>
  
  <p>If I click/tap over-and-over sometimes I am hearing sounds that have been played already much sooner than I am suppose to, often following each other.</p>
  
  <p>This has been bothering me for days but, I can't see the problem in my logic. Can you?</p>