Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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) 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #item #array #javascript
ADD COMMENT
Topic
Name
4+7 =