Answers for "how to randomly select something from a list in js"

1

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);
Posted by: Guest on March-30-2021

Code answers related to "how to randomly select something from a list in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language