class 10 science chapter 2

ch2 part 4

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Acids, Bases and Salts – Chemistry Quiz Set 2</title>

  <style>
    body {
      font-family: Arial, sans-serif;
      background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
      display: flex;
      justify-content: center;
      align-items: flex-start;
      padding: 30px;
      min-height: 100vh;
    }

    .quiz-container {
      background: #fff;
      padding: 25px;
      border-radius: 12px;
      box-shadow: 0 4px 10px rgba(0,0,0,0.2);
      width: 90%;
      max-width: 800px;
    }

    h2 { text-align: center; color: #1e3c72; }

    .question { font-weight: bold; margin: 10px 0; }

    .options label {
      display: block;
      margin: 8px 0;
      padding: 10px;
      border-radius: 6px;
      border: 1px solid #ccc;
      cursor: pointer;
      transition: 0.3s;
    }

    .options label:hover { background: #f0f0f0; }

    .correct {
      background-color: #c8f7c5 !important;
      border-color: #28a745 !important;
    }

    .wrong {
      background-color: #f8d7da !important;
      border-color: #dc3545 !important;
    }

    .explanation {
      background: #e9ecef;
      padding: 10px;
      margin-top: 10px;
      border-left: 5px solid #2a5298;
      display: none;
    }

    .controls { text-align: center; margin-top: 15px; }

    button {
      background-color: #2a5298;
      color: white;
      border: none;
      padding: 10px 20px;
      border-radius: 6px;
      cursor: pointer;
      margin: 5px;
    }

    button:hover { background-color: #1e3c72; }

    #scoreboard {
      margin-top: 25px;
      background: #eef3f7;
      padding: 15px;
      border-radius: 8px;
    }

    #scoreboard h3 { text-align: center; }

    ol { padding-left: 20px; }
  </style>
</head>

<body>

<div class="quiz-container">

  <h2>🧪 Acids, Bases and Salts – Chemistry Quiz (Set 2)</h2>

  <div id="nameSection">
    <p><strong>Enter your name to start:</strong></p>
    <input type="text" id="userName" placeholder="Your Name">
    <button onclick="startQuiz()">Start Quiz</button>
  </div>

  <div id="quizSection" style="display:none;">

    <div id="questionContainer"></div>

    <div class="controls">
      <button onclick="prevQuestion()" id="prevBtn">Previous</button>
      <button onclick="nextQuestion()" id="nextBtn">Next</button>
      <button onclick="submitQuiz()" id="submitBtn" style="display:none;">Submit</button>
    </div>

    <div id="result" style="text-align:center; margin-top:20px;"></div>

    <div id="scoreboard">
      <h3>🏆 Scoreboard</h3>
      <ol id="scoreList"></ol>
    </div>

  </div>
</div>

<script>

const questions = [

  {
    question: "1. Strong acid aur strong base se bana salt generally kaisa hota hai?",
    options: [
      "A. Acidic",
      "B. Basic",
      "C. Neutral",
      "D. Highly acidic"
    ],
    correct: 2,
    explanation: "Strong acid + strong base se bana salt generally neutral hota hai aur iska pH 7 hota hai. Sodium chloride (NaCl) iska example hai."
  },

  {
    question: "2. Strong acid aur weak base se bana salt generally kaisa hota hai?",
    options: [
      "A. Basic",
      "B. Acidic",
      "C. Neutral",
      "D. Always alkaline"
    ],
    correct: 1,
    explanation: "Strong acid + weak base se bana salt acidic nature ka hota hai. Iska pH generally 7 se less hota hai."
  },

  {
    question: "3. Common salt ka chemical name kya hai?",
    options: [
      "A. Sodium carbonate",
      "B. Sodium hydroxide",
      "C. Sodium chloride",
      "D. Sodium hydrogencarbonate"
    ],
    correct: 2,
    explanation: "Common salt ka chemical name sodium chloride (NaCl) hai. Ye hydrochloric acid aur sodium hydroxide ke reaction se bhi ban sakta hai."
  },

  {
    question: "4. Brine ke electrolysis ko kya kaha jata hai?",
    options: [
      "A. Neutralisation process",
      "B. Chlor-alkali process",
      "C. Crystallisation process",
      "D. Displacement process"
    ],
    correct: 1,
    explanation: "Aqueous sodium chloride solution, yani brine, mein electricity pass karne par sodium hydroxide, chlorine aur hydrogen bante hain. Is process ko chlor-alkali process kehte hain."
  },

  {
    question: "5. Chlor-alkali process mein chlorine gas kis electrode par release hoti hai?",
    options: [
      "A. Cathode",
      "B. Anode",
      "C. Both electrodes",
      "D. Salt bridge"
    ],
    correct: 1,
    explanation: "Brine ke electrolysis mein chlorine gas anode par aur hydrogen gas cathode par release hoti hai. Sodium hydroxide solution cathode ke paas form hota hai."
  },

  {
    question: "6. Bleaching powder banane ke liye chlorine kis compound ke saath react karta hai?",
    options: [
      "A. Sodium chloride",
      "B. Calcium carbonate",
      "C. Dry slaked lime",
      "D. Sodium hydroxide"
    ],
    correct: 2,
    explanation: "Chlorine gas ko dry slaked lime [Ca(OH)₂] ke saath react karane se bleaching powder produce hota hai. Iska representation Ca(ClO)₂ diya jata hai."
  },

  {
    question: "7. Baking soda ka chemical name kya hai?",
    options: [
      "A. Sodium carbonate",
      "B. Sodium hydrogencarbonate",
      "C. Sodium chloride",
      "D. Sodium hydroxide"
    ],
    correct: 1,
    explanation: "Baking soda ka chemical name sodium hydrogencarbonate (NaHCO₃) hai. Ye ek mild, non-corrosive basic salt hai."
  },

  {
    question: "8. Baking powder mein baking soda ke saath kaunsa weak edible acid use hota hai?",
    options: [
      "A. Hydrochloric acid",
      "B. Sulphuric acid",
      "C. Tartaric acid",
      "D. Nitric acid"
    ],
    correct: 2,
    explanation: "Baking powder mein baking soda + tartaric acid hota hai. Reaction ke during CO₂ gas produce hoti hai, jo bread ya cake ko soft aur spongy banati hai."
  },

  {
    question: "9. Sodium hydrogencarbonate (NaHCO₃) ko heat karne par kya banta hai?",
    options: [
      "A. Sodium carbonate, water aur carbon dioxide",
      "B. Sodium chloride aur oxygen",
      "C. Sodium hydroxide aur hydrogen",
      "D. Calcium carbonate aur water"
    ],
    correct: 0,
    explanation: "Heating par reaction hoti hai:<br><strong>2NaHCO₃ → Na₂CO₃ + H₂O + CO₂</strong><br>Isliye baking soda heat hone par sodium carbonate, water aur carbon dioxide produce karta hai."
  },

  {
    question: "10. Washing soda ka important use kya hai?",
    options: [
      "A. Permanent hardness of water remove karna",
      "B. Tooth decay badhana",
      "C. Oxygen produce karna",
      "D. Acids ko strong banana"
    ],
    correct: 0,
    explanation: "Washing soda, Na₂CO₃·10H₂O, ek basic salt hai. Iska use glass, soap aur paper industries, cleaning aur permanent hardness of water remove karne mein hota hai."
  }

];

let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";

function startQuiz() {

  userName = document.getElementById("userName").value.trim();

  if (!userName) {
    return alert("Please enter your name.");
  }

  document.getElementById("nameSection").style.display = "none";
  document.getElementById("quizSection").style.display = "block";

  showQuestion();
  loadScoreboard();
}

function showQuestion() {

  const q = questions[currentQuestion];
  const container = document.getElementById("questionContainer");

  container.innerHTML = `
    <div class="question">${q.question}</div>

    <div class="options">
      ${q.options.map((opt, i) => `
        <label>
          <input type="radio" name="option" value="${i}"
            ${userAnswers[currentQuestion] == i ? 'checked' : ''}>
          ${opt}
        </label>
      `).join('')}
    </div>

    <div class="explanation" id="explain${currentQuestion}">
      ${q.explanation}
    </div>
  `;

  document.getElementById("prevBtn").style.display =
    currentQuestion === 0 ? "none" : "inline-block";

  document.getElementById("nextBtn").style.display =
    currentQuestion === questions.length - 1 ? "none" : "inline-block";

  document.getElementById("submitBtn").style.display =
    currentQuestion === questions.length - 1 ? "inline-block" : "none";
}

function nextQuestion() {

  saveAnswer();

  if (currentQuestion < questions.length - 1) {
    currentQuestion++;
    showQuestion();
  }
}

function prevQuestion() {

  saveAnswer();

  if (currentQuestion > 0) {
    currentQuestion--;
    showQuestion();
  }
}

function saveAnswer() {

  const selected = document.querySelector('input[name="option"]:checked');

  userAnswers[currentQuestion] =
    selected ? parseInt(selected.value) : null;
}

function submitQuiz() {

  saveAnswer();
  score = 0;

  questions.forEach((q, index) => {
    if (userAnswers[index] === q.correct) {
      score++;
    }
  });

  showResults();
  saveScore(userName, score);
  loadScoreboard();
}

function showResults() {

  const container = document.getElementById("questionContainer");
  container.innerHTML = "";

  questions.forEach((q, index) => {

    const selected = userAnswers[index];
    const correct = q.correct;

    let optsHTML = q.options.map((opt, i) => {

      let cls = "";

      if (i === correct) cls = "correct";
      if (selected === i && selected !== correct) cls = "wrong";

      return `<label class="${cls}">${opt}</label>`;

    }).join('');

    container.innerHTML += `
      <div class="question">${q.question}</div>
      <div class="options">${optsHTML}</div>
      <div class="explanation" style="display:block;">
        ${q.explanation}
      </div>
      <hr>
    `;
  });

  document.querySelector(".controls").style.display = "none";

  document.getElementById("result").innerHTML =
    `<h3>Your Score: ${score} / ${questions.length}</h3>`;
}

function saveScore(name, score) {

  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];

  scores.push({
    name,
    score,
    date: new Date().toLocaleString()
  });

  localStorage.setItem("quizScores", JSON.stringify(scores));
}

function loadScoreboard() {

  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];

  scores.sort((a, b) => b.score - a.score);

  document.getElementById("scoreList").innerHTML =
    scores.map(s =>
      `<li>${s.name} - ${s.score}/10 (${s.date})</li>`
    ).join('');
}

</script>

</body>
</html>

Leave a Comment