I realise there is a lot of topics on this subject but I believe this one is different:
The goal is to get an value from an array on a random location then delete this value.
I use this part by John Resig (the creator of jQuery) to remove an element but it doesn't seem to listen to the location I give it
Array.prototype.remove = function(from, to) { var rest = this.slice((to || from) + 1 || this.length); this.length = from < 0 ? this.length + from : from; return this.push.apply(this, rest); }; this is how I use it
var elements = ['#1','#2','#3','#4'] var R1 = Math.floor(Math.random() * elements.length), E1 = elements.slice(R1,1) elements.remove(R1) var R2 = Math.floor(Math.random() * elements.length), E2 = elements.slice(R2,1) elements.remove(R2) var R3 = Math.floor(Math.random() * elements.length), E3 = elements.slice(R3,1) elements.remove(R3) var R4 = Math.floor(Math.random() * elements.length), E4 = elements.slice(R4,1) The problem is the remove function, it doesn't work when removing a object on a specific location I believe.