Timed quiz app
A multiple-choice quiz with a timer per question, score, review of wrong answers and a high-score table.
Beginner⏱ 4–6 hours🪜 7 stepsHTMLCSSJavaScript
What you'll learn
- ◆DOM manipulation and events
- ◆Timers with setInterval
- ◆Keeping state in one object
What you'll build
- ✓Questions loaded from a JSON file
- ✓15-second timer per question
- ✓Instant right/wrong feedback
- ✓Review screen and high scores
Step-by-step guide
- 1
Question data
questions.json: [{"q": "...", "options": ["..."], "answer": 2, "explain": "..."}]; load it with fetch.
- 2
State
Keep {index, score, answers: [], timeLeft} in one object and write render() that draws the screen from it.
- 3
Show a question
Render the question and option buttons; shuffle options with Fisher–Yates (remember the correct one).
- 4
Timer
setInterval every second; at 0 mark it wrong and move on; always clearInterval before starting a new one.
- 5
Feedback
Colour the chosen option green or red, show the explanation, then a Next button.
- 6
Results
Show the score, and list the wrong ones with the correct answer.
- 7
High scores
Save the top 5 {name, score, date} in localStorage.
🚀 Make it stand out
- +Categories and difficulty
- +Make it a PWA that works offline
- +Load questions from the Open Trivia DB API