I want to shorten my code and I am stuck. I have a quiz and for each question the answers are loaded. But I want to have a variable that does that for me.
Here is the code:
if (nr === 1) {
$('#questionmobile').html(content.inst3.question1);
$('#answer1').html(content.inst3.q1a1);
$('#answer2').html(content.inst3.q1a2);
$('#answer3').html(content.inst3.q1a3);
$('#answer4').html(content.inst3.q1a4);
} else if (nr === 2) {
$('#questionmobile').html(content.inst3.question2);
$('#answer1').html(content.inst3.q2a1);
$('#answer2').html(content.inst3.q2a2);
$('#answer3').html(content.inst3.q2a3);
$('#answer4').html(content.inst3.q2a4);
}......
As you can see its very redundant, so I thought to include the variable "nr" that has the information of the number of question. So I want something like:
$('#questionmobile').html(content.inst3.question+nr);
$('#answer1').html(content.inst3.q+nr+a1);
The concatenation +nr+ is not working, since it doesn't direct to the right JSON content.