get random element from array in javascript
Let's assume we have the following array:
var arr = [16, 8 , 'bh' , 2 , 54 , 'foo' , 8852, , 'rr' , 2145 , 34, 89, 77];
We can get a random element by typing:
var random = items[Math.floor(Math.random() * arr.length)];
Article by Morning Train Technologies