Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get a randome element from a list in javascript

let numList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let randomElem = numList[Math.floor(Math.random() * numList.length)];
console.log(randomElem);
 
PREVIOUS NEXT
Tagged: #randome #element #list #javascript
ADD COMMENT
Topic
Name
1+8 =