I'm trying to do a questionnaire like this
I create an array that contains the objects of my questionnaire inside
var cuestionario = [{
pregunta: 'pregunta1',
opciones: {
a: 'opcionA1',
b: 'opcionB1',
c: 'opcionC1',
},
correcta: 'a',
},
{
pregunta: 'pregunta2',
opciones: {
a: 'opcionA2',
b: 'opcionB2',
c: 'opcionC2',
},
correcta: 'b',
}
]
How can I create this function to check if the selected option is correct ?.
The parameter "Selected Option" is one of the Strings of the "Options" object.
function comprobarRespuesta(opcionSeleccionada) {
}
Is there any more elegant way to do this?