Answers for "random from list javascript"

10

Javascript get random item from array

var colors = ["red","blue","green","yellow"];
var randomColor = colors[Math.floor(Math.random()*colors.length)]; //pluck a random color
Posted by: Guest on July-26-2019
0

random item from array javascript

function RandomItemFromArray(myArray) {
    return myArray[Math.floor(Math.random() * myArray.length)]
}

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

let fruitSample = RandomItemFromArray(fruit)
Posted by: Guest on February-14-2021
1

js random string from array

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

Code answers related to "random from list javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language