Projects›Extra· 120 min read
Project: Quiz App
Build a multiple-choice quiz that scores the user — logic, events and the DOM working together.
What you will learn
- Store questions as an array of objects
- Render questions and handle answers
- Track and display a score
The brief
Build a small quiz: store questions as an array of objects, show each one, let the user answer, and show their final score.
- Store questions as objects:
{ question, options, answer }. - Display the current question and its option buttons.
- When an option is clicked, check it against the answer and update the score.
- At the end, show the final score out of total.
Here is the same plan as the ordered steps to build it in:
- Set up your data: make an array of question objects, each shaped
{ question, options, answer }, and ascorestarting at 0. - Track position: keep a
currentindex (starting at 0) for which question is showing. - Render the current question: read
questions[current]and show itsquestiontext plus one button per item inoptions. - Handle the answer: when an option button is clicked, compare it with that question’s
answer; if it matches, add 1 toscore. - Move on: increase
currentby 1 and render the next question — or, if there are no more, show the result. - Show the result: when
currentreaches the end, display the finalscoreout of the total number of questions.
Tip: This project cements arrays of objects, map, events and DOM updates — exactly the data-and-render pattern you will use in React.
Note: Start simple (one question working end-to-end), then loop to the next. Build incrementally — get one thing working before adding the next.
✍️ Practice
- Build a 3-question quiz that tracks and shows the score.
- Add a “Restart” button that resets the quiz.
🏠 Homework
- Add a timer, or load the questions from a JSON file with fetch.