Score quiz answers and return a result summary.
Score a quiz by matching each question with the answer the user gave. The final result should include the count, total, percentage, and a simple message.
Write these functions:
isAnswerCorrect(question, userAnswer) should return true when the user's answer matches the correct answer.
countCorrectAnswers(questions, userAnswers) should match each question with its user answer and return the number correct.
calculatePercentage(correctCount, totalQuestions) should return the percentage score.
getResultMessage(percentage) should return a short message based on the percentage.
createQuizResult(questions, userAnswers) should return correctCount, totalQuestions, percentage, and message.
Sample checks:
Expected output:
If a user answer is missing, count that question as incorrect.
Join the Community
roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login or Signup
You must be logged in to perform this action.