Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript random text from array

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

audioElement.setAttribute('src', textArray[randomNumber]);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #random #text #array
ADD COMMENT
Topic
Name
2+4 =