-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 974 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var randomno=Math.floor(Math.random()*6)+1; //random no between 1-6
var randomiceImage='dice'+randomno+".png";
var randomimgsrc='images/'+randomiceImage;
document.querySelector('.img1').setAttribute('src',randomimgsrc);
var randomno2=Math.floor(Math.random()*6)+1; //random no between 1-6
var randomiceImage2='images/'+'dice'+randomno2+".png";
document.querySelector('.img2').setAttribute('src',randomiceImage2);
if(randomno>randomno2){
document.querySelector('.heading').innerHTML='🚩PLAYER 1 WIN';
}
else if(randomno<randomno2)
{
document.querySelector('.heading').innerHTML='PLAYER 2 WIN🚩';
}
else{
document.querySelector('.heading').innerHTML='DRAW';
}
function myURL() {
window.location.reload();
}
const audio = new Audio("sound/mixkit-video-game-retro-click-237.wav");
const button = document.querySelector("button");
button.addEventListener("click", () => {
audio.play();
setTimeout(myURL, 500);
});