forked from AkhileshManda/MagicHacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
186 lines (132 loc) · 4.06 KB
/
script.js
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
const quizDB=[
{
question: "Who is Harry Potter's godfather?",
a:"Lord Voldemort",
b:"Sirius Black",
c:"Eldred Worple",
d:"Dumbledore",
ans:"ans2"
},
{
question: "What is the name of Harry Potter's owl?",
a:"Dobby",
b:"Nagini",
c:"Griphook",
d:"Hedwig",
ans:"ans4"
},
{
question: "What position does Harry play on the Quidditch team?",
a:"Chaser",
b:"Snitch",
c:"Keeper",
d:"Seeker",
ans:"ans4"
},
{
question: "Who poses as Mad-Eye Moody, Harry's 4th year Defense Against the Dark Arts professor?",
a:"Barty Crouch, Jr.",
b:"Remus Lupin",
c:"Dudley Dursley, Jr.",
d:"Newt Scamander",
ans:"ans1"
},
{
question: "Who was Hermione’s date at the Yule Ball?",
a:"Viktor Krum",
b:"Ron Weasley",
c:"Harry Potter",
d:"Oliver Wood",
ans:"ans1"
},
{
question: "V2hhdCBpcyB0aGUgc3Bl bGwgdXNlZCB0byB kaXNhcm0gc29tZW9uZT8=" ,
a:"Capacious Extremis",
b:"Expelliarmus",
c:"Disapparate",
d:"Engorgio",
ans:"ans2"
},
{
question: "Jung jnf gur svefg Ubepehk gb or qrfgeblrq?",
a:"Marvolo Gaunt's Ring",
b:"Salazar Slytherin's Locket",
c:"Tom Riddle's diary",
d:"Helga Hufflepuff's Cup",
ans:"ans3"
},
{
question: "VjJoaG RDQmpjbVZoZ EhWeVpTQnBjeUJCY21GbmIyYy8=",
a:"Dementors",
b:"Obscurus",
c:"Acromantula",
d:"Thestrals",
ans:"ans3"
},
{
question: "(92E A=2E7@C> 5@ DEF56?ED ?665 E@ 42E49 E96 EC2:? 2E z:?8VD rC@DD $E2E:@?n",
a:"Platform 9 3/4",
b:"Platform 8 2/4 ",
c:"Platform 11 3/2",
d:"Platform 4 8/9",
ans:"ans1"
},
{
question: "U3BlbGwgdGhlIGluY2FudG F0aW9uIGZvciBvbmUgb2YgdGh lIEhhbGYtQmxvb2QgUH JpbmNl4oCZcyBzcGVsbHM=",
a:"Finite Incantatem",
b:"Impedimenta",
c:"Sectumsempra",
d:"Legilimens",
ans:"ans3"
},
];
const question = document.querySelector('.question');
const option1= document.querySelector('#option1');
const option2= document.querySelector('#option2');
const option3= document.querySelector('#option3');
const option4= document.querySelector('#option4');
const submit= document.querySelector('#submit');
const answers=document.querySelectorAll('.answer');
const showscore= document.querySelector('#showscore');
let questionCount=0;
let score=0;
const loadQuestion = () =>{
question.innerText= quizDB[questionCount].question;
option1.innerText= quizDB[questionCount].a;
option2.innerText= quizDB[questionCount].b;
option3.innerText= quizDB[questionCount].c;
option4.innerText= quizDB[questionCount].d;
}
loadQuestion();
const getCheckAnswer = () => {
let answer;
answers.forEach((i) => {
if(i.checked){
answer = i.id
};
});
return answer;
};
const deselectAll = () => {
answers.forEach((i) => i.checked = false);
}
submit.addEventListener('click', () =>{
const checkedAnswer = getCheckAnswer();
if(checkedAnswer=== quizDB[questionCount].ans){
score++;
}
questionCount++;
if(questionCount<quizDB.length){
loadQuestion();
}else{
showScore.innerHTML = `
<h3 style="color: #ff8400; font-weight:1000;"> <strong> Yayy ur score ${score}/${quizDB.length}</strong> </h3>
<br>
<div class="home" style=" text-align: center;">
<button style="background-color:black ; border: none;" ><a href="finalpage.html"><p style="color:#ff8400">Go to Final Page</p></a></button>
</div>
`
;
showScore.classList.remove('scoreArea')
}
});