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
 
PREVIOUS NEXT
Tagged: #javascript #select #random #element #array
ADD COMMENT
Topic
Name
8+1 =