20 lines
469 B
JavaScript
20 lines
469 B
JavaScript
|
var audioFiles = [];
|
||
|
var numAudioFiles = 14;
|
||
|
|
||
|
// Preload the audio files
|
||
|
for (var i = 1; i <= numAudioFiles; i++) {
|
||
|
var coro = new Audio("cheers/" + i + ".ogg");
|
||
|
audioFiles.push(coro);
|
||
|
}
|
||
|
|
||
|
function coro() {
|
||
|
// Generate a random index between 0 and the number of audio files
|
||
|
var randomIndex = Math.floor(Math.random() * numAudioFiles);
|
||
|
|
||
|
// Get the randomly selected audio from the array
|
||
|
var c = audioFiles[randomIndex];
|
||
|
|
||
|
// Play the audio
|
||
|
c.play();
|
||
|
}
|