1//get random value from array
2var colors = ["red","blue","green","yellow"];
3var randColor = colors[Math.floor(Math.random() * colors.length)];
4
1var foodItems = ["Bannana", "Apple", "Orange"];
2var theFood = foodItems[Math.floor(Math.random() * foodItems.length)];
3/* Will pick a random number from the length of the array and will go to the
4corosponding number in the array E.G: 0 = Bannana */
1var items = ['Yes', 'No', 'Maybe'];
2var item = items[Math.floor(Math.random() * items.length)];
1var myArray = [
2 "Apples",
3 "Bananas",
4 "Pears"
5];
6
7var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
1const months = ["January", "February", "March", "April", "May", "June", "July"];
2
3const random = Math.floor(Math.random() * months.length);
4console.log(random, months[random]);
1let items = [12, 548 , 'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' , 2145 , 119];
2
3let randomItem = items[Math.floor(Math.random() * items.length)];