Untitled
unknown
plain_text
14 days ago
4.1 kB
5
Indexable
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hormone Hero Quiz</title> <style> body { font-family: Arial, sans-serif; text-align: center; background-color: #f4f4f4; } .container { width: 80%; max-width: 500px; margin: auto; background: white; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1 { color: #4CAF50; } .question { font-size: 18px; margin-bottom: 10px; } .options button { display: block; width: 100%; padding: 10px; margin: 5px 0; border: none; border-radius: 5px; background: #4CAF50; color: white; font-size: 16px; cursor: pointer; } .options button:hover { background: #45a049; } #result { font-size: 18px; margin-top: 20px; } </style> </head> <body> <div class="container"> <h1>Hormone Hero Quiz</h1> <div id="quiz"> <p class="question" id="questionText"></p> <div class="options" id="optionsContainer"></div> </div> <p id="result"></p> <button onclick="nextQuestion()" id="nextBtn" style="display:none;">Next Question</button> </div> <script> const quizData = [ { question: "Which hormone regulates blood sugar levels?", options: ["Cortisol", "Insulin", "Testosterone", "Thyroid"], answer: "Insulin" }, { question: "Which nutrient is essential for thyroid function?", options: ["Vitamin C", "Iodine", "Magnesium", "Iron"], answer: "Iodine" }, { question: "What type of fat supports hormone production?", options: ["Trans fats", "Saturated fats", "Omega-3 fatty acids", "Refined oils"], answer: "Omega-3 fatty acids" }, { question: "Which food is best for balancing cortisol levels?", options: ["Sugary snacks", "Leafy greens", "Processed meats", "Energy drinks"], answer: "Leafy greens" } ]; let currentQuestionIndex = 0; let score = 0; function loadQuestion() { document.getElementById("result").innerText = ""; document.getElementById("nextBtn").style.display = "none"; const currentQuestion = quizData[currentQuestionIndex]; document.getElementById("questionText").innerText = currentQuestion.question; const optionsContainer = document.getElementById("optionsContainer"); optionsContainer.innerHTML = ""; currentQuestion.options.forEach(option => { const button = document.createElement("button"); button.innerText = option; button.onclick = () => checkAnswer(option); optionsContainer.appendChild(button); }); } function checkAnswer(selectedAnswer) { const currentQuestion = quizData[currentQuestionIndex]; if (selectedAnswer === currentQuestion.answer) { score++; document.getElementById("result").innerText = "Correct! 🎉"; } else { document.getElementById("result").innerText = `Wrong! ❌ The correct answer is ${currentQuestion.answer}.`; } document.getElementById("nextBtn").style.display = "block"; } function nextQuestion() { currentQuestionIndex++; if (currentQuestionIndex < quizData.length) { loadQuestion(); } else { document.getElementById("quiz").innerHTML = `<h2>Your final score: ${score} / ${quizData.length}</h2>`; document.getElementById("nextBtn").style.display = "none"; } } loadQuestion(); </script> </body> </html>
Editor is loading...
Leave a Comment