Build an Interactive Quiz App with API Connections


π Hey everyone!
Iβm Sarfraz, and this week I built a Quiz App using vanilla JavaScript that fetches questions dynamically using an external API. It's simple, smooth, and surprisingly fun to use!
Let me walk you through the idea, tech, features, and the little UX spice I added.
π§ Tech Stack
HTML, CSS, JavaScript
Hosted on Netlify
Code managed on GitHub
π‘ What This Quiz App Can Do
Select number of questions (5, 10, 15... your choice)
Choose a category (Science, History, Computers, etc.)
Pick difficulty level (Easy / Medium / Hard)
Start answering MCQs with instant feedback
Includes a ticking sound during the quiz for added UX pressure π§ β³
π How It Works
The app uses fetch()
to get questions from the Open Trivia API based on the userβs input. Each question is displayed one by one with multiple options. After answering, it automatically moves to the next question.
To make it even more dynamic:
I added a smooth score tracking system
Timer feel with tick-tick sound in background
π₯ Behind the Code
I made sure the logic is not just functional but also reusable. The flow is designed in small functions:
getQuestions()
- to fetch and filter datadisplayQuestion()
- render current questioncheckAnswer()
- validate answer and update scoreshowResult()
- show final score with reset option
π Try It Yourself
π Live Demo
π» GitHub Repo
π¬ Watch Demo Video
π§ What I Learned
How to work with public APIs
DOM manipulation with conditionals and events
Better UX means better user retention (even in small projects!)
π£οΈ Letβs Connect
If you liked this app or want to build something similar, feel free to fork my repo or reach out! Feedback and suggestions are always welcome π¬
Thanks for reading! π
- Sarfraz
Subscribe to my newsletter
Read articles from sarfraz directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

sarfraz
sarfraz
I'm BSIT Student and want to become Full Stack Developer.