(function () {
  const questions = [
    {
      question: "1. Siapa nama asli Yabes?",
      options: ["a. Vincent", "b. Yabes", "c. Glen", "d. Reanders"],
      answer: ["b"],
    },
    {
      question: "2. Apa anime favorite Yabes?",
      options: [
        "a. Re:Zero",
        "b. That Time I Got Reincarnated as a Slime",
        "c. Mushoku Tensei",
        "d. One Piece",
      ],
      answer: ["c"],
    },
    {
      question: "3. Kira-kira Yabes umur berapa?",
      options: ["a. 1-10 tahun", "b. 10-18 tahun", "c. 18-49 tahun", "d. 50+"],
      answer: ["b"],
    },
    {
      question: "4. Apa nama panggilan Yabes?",
      options: ["a. Yab", "b. P", "c. Ngab", "d. Bes"],
      answer: ["a", "d"], // Salah satu dianggap benar
    },
    {
      question: "5. Ini JavaScript dibuat tanggal berapa?",
      options: ["a. 1 Januari 2024", "b. 2 Januari 2024", "c. 2 Januari 2025", "d. Gatau"],
      answer: ["c", "d"], // Salah satu dianggap benar
    },
  ];

  let currentQuestion = 0;

  function askQuestion() {
    if (currentQuestion >= questions.length) {
      displayResult();
      return;
    }

    const q = questions[currentQuestion];
    let questionText = q.question + "\n" + q.options.join("\n");
    let userAnswer = prompt(questionText + "\n\nKetik jawaban (a, b, c, d):");

    if (q.answer.includes(userAnswer.trim().toLowerCase())) {
      currentQuestion++;
      askQuestion();
    } else {
      alert("Jawaban salah! Aplikasi nge-crash desu!");
      throw new Error("Jawaban salah, aplikasi dihentikan desu!");
    }
  }

  function displayResult() {
    alert("Yabes Kelas: 6 SD :v");
  }

  alert("Selamat datang di quiz Yabes desu!");
  askQuestion();
})();
