Right now only one selection is allowed between all inputs. I'm not sure how to solve this. I thought the name was supposed to match between all inputs, but perhaps I'm wrong. If I remove it, then there is an endless number of input selections allowed.
How can I fix this? Thank you.
{props.Data.map((item, index) => {
return (
<div key={index}>
<h3>{item.question}</h3>
<input
type="radio"
name="answer option"
id={`answer-options-${index}`}
value={results}
onChange={e => setResults(e.target.value)}/>
<label htmlFor={`answer-options-${index}`}>
{item.answers[0]}
</label>
<input
type="radio"
name="answer option"
id={`answer-options-${index}`}
value={results.selectedAnswer}
onChange={handleSelectedAnswer}/>
<label htmlFor={`answer-options-${index}`}>
{item.answers[1]}
</label>
<input
type="radio"
name="answer option"
id={`answer-options-${index}`}
value={results.selectedAnswer}
onChange={handleSelectedAnswer}/>
<label htmlFor={`answer-options-${index}`}>
{item.answers[2]}
</label>
<input
type="radio"
name="answer option"
id={`answer-options-${index}`}
value={results.selectedAnswer}
onChange={handleSelectedAnswer}/>
<label htmlFor={`answer-options-${index}`}>
{item.answers[3]}
</label>
</div>
)
})}
<button
onClick={() => {
checkSelectedAnswer();
scoreQuiz();
finishQuiz()}
}>
Check answers
</button>