-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (19 loc) · 869 Bytes
/
Copy pathscript.js
File metadata and controls
23 lines (19 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function rola(){
var randomNumber1 = Math.floor(Math.random() * 6 + 1)
var randomDice1 = "dice" + randomNumber1 + ".png"
var randomImageSource1 = "images/" + randomDice1
var image1 = document.querySelector(".img1")
image1.setAttribute("src", randomImageSource1)
var randomNumber2 = Math.floor(Math.random() * 6 + 1)
var randomDice2 = "dice" + randomNumber2 + ".png"
var randomImageSource2 = "images/" + randomDice2
var image2 = document.querySelector(".img2")
image2.setAttribute("src", randomImageSource2)
if(randomNumber1 > randomNumber2){
document.querySelector("h1").innerHTML = "Jogador 1 Venceu"
}else if(randomNumber1 < randomNumber2){
document.querySelector("h1").innerHTML = "Jogador 2 venceu"
}else{
document.querySelector("h1").innerHTML = "Empate"
}
}