← Back CP ❓ Quiz Builder
🏰 Magic Castle — Welcome to the Wizard's Quiz Tower! A great wizard doesn't just answer questions — they create them. Today you'll build your own quiz: write questions, set the right answers, and let if/else magic check every guess. When a friend taps an answer, your conditional decides: correct → score goes up! wrong → try again! Build it, play it, share it!

⚖️ Conditionals + DOM = A Quiz That Scores Itself

In Choose Your Path you learned if/else — code that makes decisions. In Click Counter you wired up events that react to taps. Now combine them: when someone taps an answer, an if-statement checks if it's correct, and updates the DOM to show the result. That's how every quiz, poll, and form on the web works!

// When a button is tapped:
if (choice === correctAnswer) {
  score++; // add a point
  msg.textContent = "✅ Correct!";
} else {
  msg.textContent = "❌ Try again!";
}
🎯 Missions Write your first question! Play the quiz and score! Complete all 5 challenges!
📖 quiz.js — Live Code
1// Your quiz checks answers with if/else
2let score = 0;
3 
4// Question 1
5let q = "What color is the sky?";
6let choices = ["Blue","Red","Green"];
7let correct = 0; // index of right answer
8 
9checkAnswer(picked) {
10  if (picked === correct) {
11    score++; // +1 point!
12  } else {
13    // wrong — try again
14  }
15}
★ Quiz Score
0
out of 3 questions
Edit your quiz, then press Play!
🎮 Quiz Stage
My Magic Quiz
🧙
Your quiz is ready to play! Press Play Quiz below.

✏️ Quiz Editor

Pick a question to edit. Type your question, fill in the choices, then tap to mark the correct answer. The code panel updates live!

🎯 Quiz Challenges

1
📝 First Question: Edit Q1 — change the question text and mark one answer as correct with ✓.
2
🔀 Switch It Up: Edit Q2 — write a brand new question with 3 different choices.
3
Play It: Press Play Quiz and answer at least one question correctly!
4
🏆 Perfect Score: Play the whole quiz and get all 3 right — the if/else checked them all!
5
Master Quiz: Edit all 3 questions with your own text, play, and get a perfect 3/3!
🌟 Quiz Master Progress0%

🏰 Welcome to Quiz Tower!

You're about to build a real quiz — one that checks answers with if/else and keeps score. Write questions, set the correct answer, then play it yourself or share with a friend!

📝Edit Q1 — type a question and set the right answer with ✓
🔀Switch to Q2 and Q3 and make them your own
Press Play Quiz — tap answers and watch the score climb
🏆Complete 5 challenges to become a Quiz Master!