Looking for a Guide to Create a Quiz with Variable Answers

March 23, 2026 5 answers
Asked by CreativeCoder92
I'm working on a webpage for a friend who's a psychologist. We've got the basics down, but now he wants to include a quiz that provides different answers based on the user's selections. I'm not sure how to implement this and have had trouble finding tutorials that cover it. Does anyone have suggestions on how to create a simple quiz, similar to those personality tests or 'which character are you' quizzes that are common online? A video tutorial or written guide would be great! Just to clarify, this quiz is a small feature to help clients determine the services they may need, and I apologize for any language mistakes in my request.

Answers

QuizMaster68
To create your quiz, it's essential to break down your friend's vision for it. You can start simple, like using radio buttons for the answers. When a user clicks an answer, it could show a relevant service without needing to save any quiz results. You won't find a specific tutorial for this, but focus on applying what you already know from other tutorials.

UserHelper00: Are you aiming for potential clients to gauge if theyโ€™re a good match, or is it more general?

Reply to this answer
CodeWizard45
Youโ€™ll need a few key variables: the current score, user selections, and an array of objects for your questions and answers. Each question object should contain text, possible answers, and point values. Track scores in real-time as users pick answers for immediate feedback, or store answers and calculate scores at the end. For straightforward quizzes, you could use if/else or switch statements.
Reply to this answer
ScoreTracker12
Definitely set up a scoring system! Keep track of points based on user answers, then display results based on the total score. You can build this with vanilla JavaScript by storing answer values in an object, tallying them on submit, and using conditional statements to show appropriate results. If you want an easier route, look for quiz generator libraries or tutorials that guide you through building a quiz app and adapt them as needed!
Reply to this answer
EasyQuizMaker
If you prefer to keep it lightweight, consider using a point system in JavaScript. Assign points to each answer related to categories like Anxiety or Career Coaching. At the end, you reveal which category scored the highest. This approach keeps it simple and effective!
Reply to this answer
TechSavvyGuy23
What youโ€™re looking for is a way to collect the userโ€™s answers in an object format. For instance, you can create an object like `{firstName: '', lastName: ''}` and attach onChange handlers to update it as users progress. For conditional questions showing up based on certain answers, you can use some simple JavaScript logic to control visibility depending on the selected answers.

QuickCode88: You can even utilize a rendering logic example in React where certain components display based on conditions.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions