-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (24 loc) · 786 Bytes
/
script.js
File metadata and controls
31 lines (24 loc) · 786 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
28
29
30
31
function checkGuess(color) {
let randomNum = Math.floor(Math.random() * 10);
let correct = false;
if (color === "purple" && randomNum >= 0 && randomNum <= 3) {
correct = true;
} else if (color === "green" && randomNum >= 4 && randomNum <= 6) {
correct = true;
} else if (color === "orange" && randomNum >= 7 && randomNum <= 9) {
correct = true;
}
let message = correct
? "You guessed right!"
: "Oops! Wrong guess.";
showDialog(message);
}
function showDialog(message) {
let dialog = document.getElementById("dialogBox");
let dialogMsg = document.getElementById("dialogMessage");
dialogMsg.textContent = message;
dialog.classList.add("show");
}
function closeDialog() {
document.getElementById("dialogBox").classList.remove("show");
}