score:0

handleFormSubmit = () =>{
    if(answer.isCorrect){
        setScore(score+1);
    }
}

score:0

const [isCorrect, setIsCorrect] = useState(false);
const [score, setScore] = useState(0);
return <form className="answer_div" onSubmit={e => { e.preventDefault(); setScore(isCorrect === "true" ? 1 : 0); }}>
    {questions[currentQuestion].answerOptions.map((answerOption, index) => (
        <div key={index}>
            <input type="radio" name="answerOption" value={answerOption.isCorrect} onChange={e => setIsCorrect(e.target.value)} /> {answerOption.answerText}
        </div>
    ))}
    <input type="submit" value="Submit" />
</form>

Related Query

More Query from same tag