I need help with controlling the iteration of a 'for' loop in Javascript. Here is the code snippet:
for (var j=0; j < number; j++){
$('#question').empty;
$('#question').append('' + operand1[j], operator[j], operand2[j] + ' = ');
$('#answer').keyup(function() {
if($('#answer').val() == answers[j]){
return 'correct';
}
});
}
I want the iteration to occur only when return 'correct'
is triggered. Any other time, it should not iterate. How can this be achieved?
Thank you.