Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EsmailELBoBDev2/1f2a06adc7ef91c8e794cc5969441b4e to your computer and use it in GitHub Desktop.
Save EsmailELBoBDev2/1f2a06adc7ef91c8e794cc5969441b4e to your computer and use it in GitHub Desktop.
To Make Songs Work When Specific Word Appear To User From ArrayList
// This Function For The Random Array List (Random Words)
let mainJS = function() {
let randomwords = [
"I'm professional programmer",
"Noobest programmer you will ever see xD",
"So Dont Call Me Baby <br> -Ed Sheeran",
"Kiki Do You Love Me ? <br> -Drake"
];
let randomItem = Math.floor(Math.random() * randomwords.length);
document.getElementById("randomwords").innerHTML = randomwords[randomItem];
//-----------------------------------------------
/* This Function For The Songs (Witch Will Play When Specific Word Will Appear To User
From The Random Array List (Random Words) */
let ed = new Audio("songs/ed.mp3");
let drake = new Audio("songs/drake.mp3");
if (randomItem ==2) {
ed.play();
} else if (randomItem ==3) {
drake.play();
}
}
mainJS();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment