-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (22 loc) · 877 Bytes
/
script.js
File metadata and controls
27 lines (22 loc) · 877 Bytes
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
const holdBtn = document.getElementById("hold");
const rollBtn = document.getElementById("roll");
holdBtn.addEventListener("click", hold);
rollBtn.addEventListener("click", roll);
let holdValue = 0;
let score = 0;
function hold() {
holdValue += 5;
document.getElementById("p1-hold").style.width = holdValue + "%";
document.getElementById("p1-hold").setAttribute("aria-valuenow", holdValue);
document.getElementById("p1-hold").innerText = holdValue;
score += 10;
document.getElementById("p1-score").style.width = score + "%";
document.getElementById("p1-score").setAttribute("aria-valuenow", score);
document.getElementById("p1-score").innerText = score;
}
function roll() {
const faceValue = Math.floor(Math.random() * 6) + 1;
const output = "ɨ" + (faceValue - 1) + "; ";
const die = document.getElementById("die");
die.innerHTML = output;
}