I currently have a unique multiple choice test where some of the questions have multiple choice that are all correct. I'm currently trying to write something to check if every answer is question within the choice. choices is prop of type Array which holds multiple choice questions. I want to be able to check that isCorrect is true for each object within this.props.choices. Currently the structure looks like this:
"choices": [
{
"text": "Text 1",
"isCorrect": true,
},
{
"text": "Text 2",
"isCorrect": true,
}
]
you want to use every on array so like this:
choices.every(choice => choice.isCorrect)
this will return true if all values are true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With