JSFiddle - React, Tailwind, and code Playground

by Gerri Berendzen

HTML

<div id="ap-quiz-box"><div class="special">
    <div class="game-container">
      <div id="start-screen">
        <h1 class="game">Editor-in-Chief Challenge</h1>
        <p class="game2">
          The deadline is approaching! Fix these sentences according to
          <b>AP Style</b> rules.
        </p>
        <button id="start-btn">Start Editing</button>
      </div>

      <div id="quiz-screen" class="hidden">
        <div class="stat-bar">
          <span>Score: <span id="score">0</span></span>
          <span>Question: <span id="q-count">1</span></span>
        </div>
        <div class="question" id="question-text">Loading...</div>
        <div class="options" id="options-container"></div>
        <div id="feedback" class="feedback"></div>
      </div>

      <div id="end-screen" class="hidden">
        <h1>Edition Published!</h1>
        <p>Your final editing score: <span id="final-score">0</span>/10</p>
        <button onclick="location.reload()">Try Again</button>
      </div>
    </div>
  </div>

CSS

#ap-quiz-box .special {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background: #f4f4f9;
      display: block;
      min-height: 420px;
      padding: 2rem 1rem;
      border-radius: 12px;
      margin: 0 auto;
      width: 100%;
      box-sizing: border-box;
    }
    #ap-quiz-box .game-container {
      background: white;
      padding: 2rem;
      border-radius: 12px;
      box-shadow: 0 10px 25px rgba(0,0,0,0.1);
      width: 90%;
      max-width: 600px;
      margin: 0 auto;
      text-align: center;
      box-sizing: border-box;
    }
    #ap-quiz-box .game2 {
      font-family: Verdana, sans-serif;
      font-size: 12pt;
    }
    #ap-quiz-box .hidden {
      display: none;
    }
    #ap-quiz-box .game {
      color: #2c3e50;
      margin-top: 0;
    }
    #ap-quiz-box .stat-bar {
      display: flex;
      justify-content: space-between;
      margin-bottom: 20px;
      font-weight: bold;
      color: #7f8c8d;
    }
    #ap-quiz-box .question {
      font-size: 1.2rem;
      margin-bottom: 1.5rem;
      color: #34495e;
      min-height: 60px;
    }
    #ap-quiz-box .options {
      display: grid;
      gap: 10px;
    }
    #ap-quiz-box button {
      padding: 15px;
      border: 2px solid #3498db;
      background: white;
      color: #2c3e50;
      border-radius: 8px;
      cursor: pointer;
      transition: 0.2s;
      font-size: 1rem;
    }
    #ap-quiz-box button:hover {
      background: #3498db;
      color: white;
    }
    #ap-quiz-box .feedback {
      margin-top: 20px;
      font-weight: bold;
      min-height: 24px;
      line-height: 1.45;
    }
    #ap-quiz-box .correct {
      color: #27ae60;
    }
    #ap-quiz-box .wrong {
      color: #e74c3c;
    }
    #ap-quiz-box #start-btn {
      background: #27ae60;
      color: white;
      border: none;
      padding: 15px 30px;
      font-size: 1.2rem;
    }

JavaScript

<script>
    (() => {
      const quizData = [
        {
          q: "Which sentence correctly follows AP Style for dates?",
          options: ["The event is on Oct. 24.", "The event is on October 24th.", "The event is on Oct. 24th."],
          correct: 0,
          explanation: "AP Style abbreviates months only with specific dates (Oct., not October) and uses cardinal numbers rather than ordinals (24, not 24th)."
        },
        {
          q: "How should you write a street address according to AP rules?",
          options: ["1600 Pennsylvania Avenue", "1600 Pennsylvania Ave.", "1600 Pennsylvania Ave"],
          correct: 1,
          explanation: "Abbreviate Ave., Blvd. and St. only with numbered addresses (1600 Pennsylvania Ave.), and spell them out without a number."
        },
        {
          q: "Identify the correct use of numerals:",
          options: ["She has 9 cats.", "She has nine cats.", "She has (9) cats."],
          correct: 1,
          explanation: "Spell out whole numbers below 10 (nine) and use figures for 10 and above in standard prose."
        },
        {
          q: "Which is correct for a formal title before a name?",
          options: ["The Vice President Kamala Harris...", "Vice Pres. Kamala Harris...", "Vice President Kamala Harris..."],
          correct: 2,
          explanation: "Capitalize formal titles when they appear directly before one or more names, and spell out vice president."
        },
        {
          q: "Does AP Style typically use the Oxford Comma?",
          options: ["Yes: red, white, and blue.", "No: red, white and blue."],
          correct: 1,
          explanation: "In simple series, AP Style generally omits the serial (Oxford) comma before the conjunction unless needed for clarity."
        },
        {
          q: "Which correctly follows AP style for the movie <i>Rocky Horror Picture Show</i>?",
          options: ["He went to “The Rocky Horror Picture...