Browse Source

fix: answer selection order issue

main
Abdul Basit 1 year ago
parent
commit
9c3834035e
  1. 6
      src/components/QuestionScreen/index.tsx

6
src/components/QuestionScreen/index.tsx

@ -86,9 +86,9 @@ const QuestionScreen: FC = () => {
const { question, type, choices, correctAnswers } = currentQuestion
const onClickNext = () => {
const isMatch: boolean = correctAnswers.every(
(answer: string, index: number) => answer === selectedAnswer[index]
)
const isMatch: boolean =
selectedAnswer.length === correctAnswers.length &&
selectedAnswer.every((answer) => correctAnswers.includes(answer))
// adding selected answer, and if answer matches key to result array with current question
setResult([...result, { ...currentQuestion, selectedAnswer, isMatch }])

Loading…
Cancel
Save