javascript get random number of list in js code example
Example 1: pick a random element from an array javascript
var myArray = [
"Apples",
"Bananas",
"Pears"
];
var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
Example 2: get random elements from array javascript
array.sort(() => Math.random() - Math.random()).slice(0, n)