Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

1 thought on “Hello world!”

Leave a Comment

Your email address will not be published. Required fields are marked *

document.addEventListener("DOMContentLoaded", function () { const physicsQuestions = [ { q: "What is the speed of light?", options: ["3x10^8 m/s", "3x10^6 m/s", "1.5x10^8 m/s", "3x10^5 m/s"], answer: 0 }, { q: "Unit of Force?", options: ["Joule", "Newton", "Pascal", "Watt"], answer: 1 }, { q: "Which law explains action and reaction?", options: ["Newton's 1st Law", "Newton's 2nd Law", "Newton's 3rd Law", "Law of Gravitation"], answer: 2 }, { q: "1 Horsepower = ?", options: ["746 W", "1000 W", "500 W", "1500 W"], answer: 0 }, { q: "Who discovered electron?", options: ["Newton", "Einstein", "Thomson", "Rutherford"], answer: 2 } // ⚡ Yaha baaki 45 questions add karenge ]; let currentIndex = 0; let score = 0; const qText = document.getElementById("question-physics"); const optBox = document.getElementById("options-physics"); const scoreBox = document.getElementById("score-physics"); const resultBox = document.getElementById("result-physics"); function loadPhysicsQuestion() { if (currentIndex < physicsQuestions.length) { let currentQ = physicsQuestions[currentIndex]; qText.textContent = currentQ.q; optBox.innerHTML = ""; currentQ.options.forEach((opt, i) => { let btn = document.createElement("button"); btn.textContent = opt; btn.onclick = () => checkPhysicsAnswer(i); optBox.appendChild(btn); }); } else { showPhysicsResult(); } } function checkPhysicsAnswer(selected) { if (selected === physicsQuestions[currentIndex].answer) { score += 10; new Audio("https://www.myinstants.com/media/sounds/correct.mp3").play(); } else { score -= 5; new Audio("https://www.myinstants.com/media/sounds/wrong-answer-sound-effect.mp3").play(); } currentIndex++; loadPhysicsQuestion(); } function showPhysicsResult() { document.getElementById("quiz-box-physics").style.display = "none"; resultBox.style.display = "block"; scoreBox.textContent = `You scored ${score} points out of ${physicsQuestions.length * 10}`; } window.restartQuiz = function () { currentIndex = 0; score = 0; resultBox.style.display = "none"; document.getElementById("quiz-box-physics").style.display = "block"; loadPhysicsQuestion(); }; loadPhysicsQuestion(); });
Scroll to Top