Answers for "random item of a list js"

8

javascript math.random from list

var myArray = [
  "Apples",
  "Bananas",
  "Pears"
];

var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
Posted by: Guest on April-19-2020
1

get random item from array javascript

const randomElement = array[Math.floor(Math.random() * array.length)];
Posted by: Guest on April-07-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language