-
Notifications
You must be signed in to change notification settings - Fork 1
/
aoc-cyber.js
41 lines (36 loc) · 1.24 KB
/
aoc-cyber.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
document.getElementById("quiz-form").addEventListener("submit", function(event) {
event.preventDefault();
// Getting the user answers
const answers = {
q1: document.getElementById("q1").value.trim().toLowerCase(),
q2: document.getElementById("q2").value.trim().toLowerCase(),
q3: document.getElementById("q3").value.trim().toLowerCase(),
q4: document.getElementById("q4").value.trim().toLowerCase(),
q5: document.getElementById("q5").value.trim().toLowerCase()
};
// Correct answers
const correctAnswers = {
q1: "confidentiality integrity availability",
q2: "encryption",
q3: "phishing",
q4: "vulnerability",
q5: "distributed denial of service"
};
// Flag if all answers are correct
let allCorrect = true;
for (let key in correctAnswers) {
if (answers[key] !== correctAnswers[key]) {
allCorrect = false;
break;
}
}
// Display result
const resultDiv = document.getElementById("result");
if (allCorrect) {
resultDiv.innerHTML = "Congratulations! Your flag is: <strong>AOC{cyberFlag456}</strong>";
resultDiv.style.color = "#2ea043";
} else {
resultDiv.innerHTML = "Oops! One or more answers are incorrect. Try again!";
resultDiv.style.color = "#ff0000";
}
});