-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
20 lines (15 loc) · 731 Bytes
/
index.js
File metadata and controls
20 lines (15 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let randomNumber1 = Math.floor(Math.random() * 6) + 1;
let randomImage = 'dice' + randomNumber1 + '.png'
let randomImageFolder = 'images/' + randomImage
document.querySelectorAll('img')[0].setAttribute('src', randomImageFolder)
let randomNumber2 = Math.floor(Math.random() * 6) + 1;
let randomImage2 = 'dice' + randomNumber2 + '.png'
let randomImageFolder2 = 'images/' + randomImage2
document.querySelectorAll('img')[1].setAttribute('src', randomImageFolder2)
if (randomNumber1 > randomNumber2) {
document.querySelector('h1').innerHTML = 'PLAYER 1 WINS'
} else if (randomNumber1 < randomNumber2) {
document.querySelector('h1').innerHTML = 'PLAYER 2 WINS';
} else {
document.querySelector('h1').innerHTML='DRAW!';
}