how to get a random element of an array javascript
var foodItems = ["Bannana", "Apple", "Orange"];
var theFood = foodItems[Math.floor(Math.random() * foodItems.length)];
/* Will pick a random number from the length of the array and will go to the
corosponding number in the array E.G: 0 = Bannana */
let fruits = ["Apple", "Banana", "Mango", "Orange"]; // array
let index = Math.floor(Math.random() * fruits.length); // random index
console.log(fruits[index]); // result
//This is an example of a Temporal Literal
lunchParty = ["Angela", "Ben", "Jenny", "Michael", "Chloe"];
function whosPaying(names) {
let upperBound = names.length;
let PersonBuyingLunch = Math.floor(Math.random() * upperBound)
return names[PersonBuyingLunch]
}
//below are backticks, not single quotes
alert(`${whosPaying(lunchParty)} is buying lunch today`)
whosePaying(lunchParty)