-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz.js
71 lines (69 loc) · 2.13 KB
/
quiz.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
document.getElementById("button").addEventListener("click", process);
document.getElementById("corr1").style.display = "none";
document.getElementById("corr2").style.display = "none";
document.getElementById("corr3").style.display = "none";
document.getElementById("corr4").style.display = "none";
function process() {
//INPUT
let in1 = document.getElementById("in1").value.toLowerCase();
let in2 = document.getElementById("in2").value.toLowerCase();
let in3 = document.getElementById("in3").value.toLowerCase();
let in4 = document.getElementById("in4").value.toLowerCase();
let true_arr = [false, false, false, false];
let correct = 0;
let advice_arr = [
"Read Better. Don't you speak English?",
"My Goodness. Go back to Kindergarden",
"Ok, not bad",
"Good job, but why not 100%?",
"Good Boy. You get a star!",
];
//PROCESS
if (in1 == "ethiopia" || in1 == "abyssinia") {
correct += 1;
true_arr[0] = true;
}
if (in2 == "britain") {
correct += 1;
true_arr[1] = true;
}
if (
in3 == "tweodros" ||
in3 == "emperor tweodros" ||
in3 == "emperor tweodros ii"
) {
correct += 1;
true_arr[2] = true;
}
if (in4 == 1868) {
correct += 1;
true_arr[3] = true;
}
//OUTPUT
document.getElementById("output").innerHTML = `Your Grade: ${
(correct / 4) * 100
}%`;
document.getElementById("advice").innerHTML = advice_arr[correct];
for (let x = 0; x <= 3; x++) {
if (true_arr[0] == false) {
document.getElementById("corr1").style.display = "block";
} else {
document.getElementById("corr1").style.display = "none";
}
if (true_arr[1] == false) {
document.getElementById("corr2").style.display = "block";
} else {
document.getElementById("corr2").style.display = "none";
}
if (true_arr[2] == false) {
document.getElementById("corr3").style.display = "block";
} else {
document.getElementById("corr3").style.display = "none";
}
if (true_arr[3] == false) {
document.getElementById("corr4").style.display = "block";
} else {
document.getElementById("corr4").style.display = "none";
}
}
}