-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (64 loc) · 1.83 KB
/
script.js
File metadata and controls
72 lines (64 loc) · 1.83 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
// কুইজ ডেটা
const quizData = [
{
question: "JavaScript কোন ধরনের ভাষা?",
options: ["Markup", "Programming", "Styling", "Database"],
answer: "Programming",
},
{
question: "HTML-এর পূর্ণরূপ কী?",
options: [
"HyperText Markup Language",
"HighText Machine Language",
"Hyper Transfer Markup Language",
"None",
],
answer: "HyperText Markup Language",
},
{
question: "CSS কী কাজে লাগে?",
options: [
"লেআউট ডিজাইন",
"ডেটা সংরক্ষণ",
"সার্ভার চালানো",
"ক্যালকুলেশন করা",
],
answer: "লেআউট ডিজাইন",
},
];
let currentQuestion = 0;
let score = 0;
const questionEl = document.getElementById("question");
const optionsEl = document.getElementById("options");
const resultEl = document.getElementById("result");
function loadQuestion() {
const q = quizData[currentQuestion];
questionEl.textContent = q.question;
optionsEl.innerHTML = "";
q.options.forEach((option) => {
const btn = document.createElement("button");
btn.classList.add("option-btn");
btn.textContent = option;
btn.onclick = () => checkAnswer(option);
optionsEl.appendChild(btn);
});
}
function checkAnswer(selected) {
const correct = quizData[currentQuestion].answer;
if (selected === correct) {
score++;
}
currentQuestion++;
if (currentQuestion < quizData.length) {
loadQuestion();
} else {
showResult();
}
}
function showResult() {
questionEl.textContent = "✅ কুইজ শেষ!";
optionsEl.innerHTML = "";
resultEl.textContent = `তোমার স্কোর: ${score} / ${quizData.length}`;
}
// শুরু করো
loadQuestion();