I have a questionnaire, which returns yes and no answers. I want my array to hold all the yes/no answers, however, it seems to overwrite the current in the array?
Is .push being used correctly here?
const handleAnswerOptionOnClick = (answerText) => {
let results = [];
results.push(answerText);
const nextQuestion = currentQuestion + 1;
if (nextQuestion < questions.length) {
setCurrentQuestion(nextQuestion);
}
};
My array always returns 1 value, such as:
['No']
When I would like:
['No', 'Yes', 'No]