{"id":1509,"date":"2023-08-26T21:22:36","date_gmt":"2023-08-26T15:22:36","guid":{"rendered":"https:\/\/jeffreyyounggren.com\/?p=1509"},"modified":"2023-08-26T21:22:41","modified_gmt":"2023-08-26T15:22:41","slug":"bearded-dragon-quiz","status":"publish","type":"post","link":"https:\/\/jeffreyyounggren.com\/bearded-dragon-quiz\/","title":{"rendered":"Bearded Dragon Quiz: How Well Do You Know About Your Beardie?"},"content":{"rendered":"\n

Welcome to the Bearded Dragon Quiz, a place where your knowledge about your beloved pet will be tested. Are you a bearded dragon enthusiast?<\/p>\n\n\n\n

See how much you know about these fascinating creatures with this fun and challenging quiz! Test your knowledge and learn more about the amazing world of bearded dragons.<\/p>\n\n\n\n

Let the quiz begin!<\/p>\n\n\n\n\n Bearded Dragon Quiz<\/title>\n <style>\n \/* Add CSS styles for quiz *\/\n body \n .question {\n margin-top: 20px;\n margin-bottom: 10px;\n font-weight: bold;\n }\n .choices {\n display: flex;\n flex-wrap: wrap;\n margin-bottom: 20px;\n }\n .choice {\n margin: 5px;\n padding: 10px;\n border: 1px solid #ccc;\n border-radius: 5px;\n cursor: pointer;\n }\n .choice:hover {\n background-color: #f5f5f5;\n }\n .choice.selected {\n background-color: #4CAF50;\n color: white;\n }\n #submit-btn {\n margin-top: 20px;\n padding: 10px 20px;\n border: none;\n border-radius: 5px;\n background-color: #4CAF50;\n color: white;\n font-weight: bold;\n cursor: pointer;\n }\n #submit-btn:hover {\n background-color: #3e8e41;\n }\n <\/style>\n \n \n <h1>Bearded Dragon Quiz<\/h1>\n <div id=\"quiz\">\n <div id=\"question-container\"><\/div>\n <button id=\"submit-btn\">Submit<\/button>\n <\/div>\n <script>\n \/\/ Define quiz questions and answers\n const quizData = [\n {\n question: \"What is the scientific name for bearded dragons?\",\n choices: [\"Pogona vitticeps\", \"Pogona barbata\", \"Pogona henrylawsoni\", \"Pogona mitchelli\"],\n answer: \"Pogona vitticeps\"\n },\n {\n question: \"What is the average lifespan of a bearded dragon?\",\n choices: [\"5-7 years\", \"8-10 years\", \"11-13 years\", \"14-16 years\"],\n answer: \"8-10 years\"\n },\n {\n question: \"What type of environment do bearded dragons need?\",\n choices: [\"Desert\", \"Rainforest\", \"Arctic\", \"Aquatic\"],\n answer: \"Desert\"\n }\n ];\n\n \/\/ Get DOM elements\n const questionContainer = document.getElementById(\"question-container\");\n const submitBtn = document.getElementById(\"submit-btn\");\n\n \/\/ Initialize quiz\n let currentQuestion = 0;\n let score = 0;\n showQuestion();\n\n \/\/ Function to display a question\n function showQuestion() {\n \/\/ Clear question container\n questionContainer.innerHTML = \"\";\n\n \/\/ Add question text\n const question = document.createElement(\"div\");\n question.classList.add(\"question\");\n question.innerText = quizData[currentQuestion].question;\n questionContainer.appendChild(question);\n\n \/\/ Add choices\n const choices = document.createElement(\"div\");\n choices.classList.add(\"choices\");\n quizData[currentQuestion].choices.forEach(choice => {\n const choiceEl = document.createElement(\"div\");\n choiceEl.classList.add(\"choice\");\n choiceEl.innerText = choice;\n choiceEl.addEventListener(\"click\", () => {\n \/\/ Mark selected choice\n const selectedChoice = document.querySelector(\".choice.selected\");\n if (selectedChoice) {\n selectedChoice.classList.remove(\"selected\");\n}\nchoiceEl.classList.add(\"selected\");\n});\nchoices.appendChild(choiceEl);\n});\nquestionContainer.appendChild(choices);\n} \n \/\/ Function to check answer and move to next question\n function checkAnswer() {\n \/\/ Check if an answer is selected\n const selectedChoice = document.querySelector(\".choice.selected\");\n if (!selectedChoice) {\n alert(\"Please select an answer.\");\n return;\n }\n\n \/\/ Check if answer is correct\n const answer = quizData[currentQuestion].answer;\n if (selectedChoice.innerText === answer) {\n score++;\n }\n\n \/\/ Move to next question or finish quiz\n currentQuestion++;\n if (currentQuestion < quizData.length) {\n showQuestion();\n } else {\n finishQuiz();\n }\n }\n\n \/\/ Function to finish quiz and display score\n function finishQuiz() {\n \/\/ Clear quiz container\n questionContainer.innerHTML = \"\";\n\n \/\/ Display score\n const scoreText = document.createElement(\"h2\");\n scoreText.innerText = `You scored ${score} out of ${quizData.length}!`;\n questionContainer.appendChild(scoreText);\n\n \/\/ Hide submit button\n submitBtn.style.display = \"none\";\n }\n\n \/\/ Attach event listener to submit button\n submitBtn.addEventListener(\"click\", checkAnswer);\n<\/script>\n\n\n\n<p>Let us know in the comment section how many of them got right.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to the Bearded Dragon Quiz, a place where your knowledge about your beloved pet will be tested. Are you a bearded dragon enthusiast? See how much you know about these fascinating creatures with this fun and challenging quiz! Test your knowledge and learn more about the amazing world of bearded dragons. Let the quiz […]<\/p>\n","protected":false},"author":2,"featured_media":8437,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/posts\/1509"}],"collection":[{"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/comments?post=1509"}],"version-history":[{"count":11,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"predecessor-version":[{"id":3979,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/posts\/1509\/revisions\/3979"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/media\/8437"}],"wp:attachment":[{"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeffreyyounggren.com\/wp-json\/wp\/v2\/tags?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}