Answers for "random words from list in javascript"

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
0

javascript random text from array

var textArray = [
    'song1.ogg',
    'song2.ogg'
];
var randomNumber = Math.floor(Math.random()*textArray.length);

audioElement.setAttribute('src', textArray[randomNumber]);
Posted by: Guest on April-05-2021

Code answers related to "random words from list in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language