Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript select random element from array

let fruits = ["Apple", "Banana", "Mango", "Orange"]; // array
let index = Math.floor(Math.random() * fruits.length); // random index
console.log(fruits[index]); // result
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #select #random #element #array
ADD COMMENT
Topic
Name
6+6 =