If you need to use this often for arrays, I would add a function to the array prototype:
Array.prototype.randomPick = function(){
var M = this.length-1;
var N = 0;
var randomIndex = Math.floor(Math.random()*(1+M-N))+N;
return this[randomIndex];
};
Then you can call it:
var arr = [2,3,4,5,4,6,8,9,7];
alert(arr.randomPick());
________ John Y. Developer