Every project / Useful Apps

❓ Tech Trivia

A quiz app about computers and the internet. Swap in your own questions on any subject.

Tech Trivia running
Language
HTML, CSS & JavaScript
Level
Beginner
Category
Useful Apps
▶ Try it & remix

What you'll learn

  • Arrays of objects
  • Creating buttons from data
  • Keeping score
  • Shuffling
  • CSS transitions

How it works

  • The questions live in questions.js as a list of objects: the question, its choices, and which choice is right.
  • Each game shuffles them with the Fisher–Yates shuffle, a fair way to mix up a list.
  • The answer buttons are built from that data, so adding a question needs no new HTML.
  • Your score updates as you go, and the last screen shows your percentage.

Files

FileLines
index.html20the page: what shows up
questions.js34Change these to quiz people on anything! `answer` is the position of the right choice (0 = first)
quiz.js84what it does
style.css76how it looks

Challenges

Each one is a bit harder than the last. Teachers: these make good assignment instructions.

  1. Write 5 questions about a subject you love and replace mine.
  2. Show a progress bar at the top.
  3. Add a 10-second timer for each question.
  4. Show which questions you got wrong at the end, with the right answers.
  5. Keep a high-score table with names in localStorage.