Skip to content

Commit 61ad6fb

Browse files
committed
update quiz correctAnswers logic
1 parent 55eee82 commit 61ad6fb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/quiz.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ function generateQuiz(containerId, title, question, options, correctAnswers) {
5252
messageElement.style.display = 'none';
5353
messageElement.style.opacity = 0;
5454

55-
if (correctAnswers === option) {
55+
isCorrect = false
56+
if (Array.isArray(correctAnswers)) {
57+
isCorrect = correctAnswers.some(ans => ans === option);
58+
} else {
59+
isCorrect = correctAnswers === option
60+
}
61+
62+
if (isCorrect) {
5663
const emojis = ["🍀", "🎉", "🌈", "🚀", "🌟", "✨", "💯"];
5764
const emoji = emojis[~~(Math.random() * emojis.length)];
5865
messageBody.innerHTML = `<strong style="color: #0E76BC !important; font-size: 16px">Correct! &nbsp;${emoji}</strong><br>${explanation}`;

0 commit comments

Comments
 (0)