var myArray = [
"Apples",
"Bananas",
"Pears"
];
var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
let fruits = ["Apple", "Banana", "Mango", "Orange"]; // array
let index = Math.floor(Math.random() * fruits.length); // random index
console.log(fruits[index]); // result
function choose(choices) {
var index = Math.floor(Math.random() * choices.length);
return choices[index];
}
var item = items[Math.floor(Math.random()*items.length)];
let index=Math.floor(Math.random()*quotes.length);
<!--This will give a random quote-->
quotes[index];
//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)