-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
87 lines (64 loc) · 1.98 KB
/
script.js
File metadata and controls
87 lines (64 loc) · 1.98 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//GET WHEEL VARIABLES
// let wheel = document.getElementById("wheel");
//4 colors = red, yellow, blue, green
let redButton = document.getElementById("BtnR");
let brownButton = document.getElementById("BtnBr");
let blueButton = document.getElementById("BtnB");
let greenButton = document.getElementById("BtnG");
let button = document.getElementsByTagName("button");
//rand no from 0-12
let randomNumber = 11 * Math.random().toFixed(1);
console.log(randomNumber);
document.getElementById("message").textContent = "Pick A Color To Spin & Win";
//if statement specifying color balls each
// red ball
button.addEventListener("click", proceed);
function proceed() {
location.reload();
if (randomNumber > 0 && randomNumber <= 2) {
alert("You guessed right!. The color is Red!🥳🙌");
}
else {
alert("Oops, you guessed wrong...Try Again!!");
}
}
proceed();
//purple ball
button.addEventListener("click", proceed1);
async function proceed1() {
location.reload();
// setTimeout(() => {
// alert("this is the delayed alert!");
// }, 3000);
if (randomNumber > 2 && randomNumber <= 5) {
alert("You guessed right!. The color is Purple!🥳🙌");
}
else {
alert("Oops, you guessed wrong...Try Again!!");
}
}
proceed1();
//blue ball
button.addEventListener("click", proceed2);
function proceed2() {
location.reload();
if (randomNumber > 5 && randomNumber <= 8) {
alert("You guessed right!. The color is Blue!🥳🙌");
}
else {
alert("Oops, you guessed wrong...Try Again!!");
}
}
proceed2();
//green ball
button.addEventListener("click", proceed3);
function proceed3() {
location.reload();
if (randomNumber > 8 && randomNumber <= 11) {
alert("You guessed right!. The color is Green!🥳🙌");
}
else {
alert("Oops, you guessed wrong...Try Again!!");
}
}
proceed3();