-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
97 lines (87 loc) · 2.73 KB
/
script.js
File metadata and controls
97 lines (87 loc) · 2.73 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
88
89
90
91
92
93
94
95
96
97
//Global Variables
//This is where you will define the variables you will be using in your project.
//#TODO: Create four variables to track each possible quiz outcome
var questionCount = 0;
var fallSeason = 0;
var springSeason = 0;
var winterSeason = 0;
var summerSeason = 0;
//#TODO: Use the DOM to create variables for the first quiz question.
var q1a1 = document.getElementById("q1a1");
var q1a2 = document.getElementById("q1a2");
var q1a3 = document.getElementById("q1a3");
var q1a4 = document.getElementById("q1a4");
var q2a1 = document.getElementById("q2a1");
var q2a2 = document.getElementById("q2a2");
var q2a3 = document.getElementById("q2a3");
var q2a4 = document.getElementById("q2a4");
var q3a1 = document.getElementById("q3a1");
var q3a2 = document.getElementById("q3a2");
var q3a3 = document.getElementById("q3a3");
var q3a4 = document.getElementById("q3a4");
var result = document.getElementById("result");
var restart= document.getElementById("restart");
//#TODO: Add Event Listeners to your answer choice variables.
q1a1.addEventListener("click", fall);
q1a2.addEventListener("click", winter);
q1a3.addEventListener("click", summer);
q1a4.addEventListener("click", spring);
q2a1.addEventListener("click", summer);
q2a2.addEventListener("click", spring);
q2a3.addEventListener("click", fall);
q2a4.addEventListener("click", winter);
q3a1.addEventListener("click", winter);
q3a2.addEventListener("click", fall);
q3a3.addEventListener("click", summer);
q3a4.addEventListener("click", spring);
restart.addEventListener("click", restart);
//#TODO: Define quiz functions here
function fall() {
fallSeason += 1;
questionCount += 1;
//alert("Pumpkin Spice Latte?!");
if (questionCount >= 3) {
updateResult();
}
}
function spring() {
springSeason += 1;
questionCount += 1;
//alert("Bees! NOO T-T");
if (questionCount >= 3) {
updateResult();
}
}
function winter() {
winterSeason += 1;
questionCount += 1;
//alert("Frostbite! NOO T-T");
if (questionCount >= 3) {
updateResult();
}
}
function summer() {
summerSeason += 1;
questionCount += 1;
//alert("Sunburn!NOO T-T");
if (questionCount >= 3) {
updateResult();
}
}
function updateResult(){
if (fallSeason>= 2){
result.innerHTML="You are the season fall🍁--you are chill and go with the flow";
}
else if(summerSeason>= 2){
result.innerHTML="You are the season summer🔆--you are friendly and ambitious";
}
else if(winterSeason>= 2){
result.innerHTML="You are the season winter🎿--you are bold and like to take lead";
}
else if(springSeason>= 2){
result.innerHTML="You are the season spring🌷--you are a mellow person and like to hang out with friends";
}
else{
result.innerHTML="I'm not sure..(you might be all the seasons(⌐■_■))";
}
}