Added Random.pop()

This commit is contained in:
pyoor 2017-04-12 10:40:50 -04:00
parent 5dbe5b7fa6
commit 05ad767b05

View file

@ -141,5 +141,14 @@ var random = {
result.push(this.pick(list)); result.push(this.pick(list));
} }
return result; return result;
},
pop: function (arr) {
// Removes and returns a random item from an array
var i, obj;
obj = Random.item(arr);
arr.splice(arr.indexOf(obj), 1);
return obj;
} }
}; };