1//get random value from array
2var colors = ["red","blue","green","yellow"];
3var randColor = colors[Math.floor(Math.random() * colors.length)];
4
1let items = [12, 548 , 'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' , 2145 , 119];
2
3let randomItem = items[Math.floor(Math.random() * items.length)];
1//Function to make it easier
2Array.prototype.random = function() {
3 return this[Math.floor((Math.random() * this.length))];
4};
5
6var colors = ["red","blue","green","yellow"];
7var randomColor = colors.random();