I need to get the indexes of the items in question.options array that have 'correct: true' on them. It only returns the first index (because of findIndex), need to retrieve all indexes that match (for questions with more than one answer). I'll then need to add one to each of the indexes for correctAnswerOptions array to pass to another function. Here's my code.
getCorrectAnswers(question: QuizQuestion) {
console.log(question.options.findIndex(item => item.correct));
const identifiedCorrectAnswers = question.options.filter(item => item.correct);
this.numberOfCorrectOptions = identifiedCorrectAnswers.length;
// need to push the correct answer option numbers here!
this.correctAnswers.push(identifiedCorrectAnswers);
// pass the correct answers
this.setExplanationAndCorrectAnswerMessages(this.correctAnswers);
return identifiedCorrectAnswers;
}