Why does the click method return undefined after the for in loop iterates over the first array of answer objects?
var i = 0;
var j = 0;
var allQuestions = [{question:"What is the color of the sky?",answer:["blue","yellow",
"red"],correctAnswer:["blue",1]},{question:"What is the opposite of
up?",answer:["down","sideways", "circle"],correctAnswer:["down",1]},
{question:"What is the first number?",answer:["1","5", "7"],correctAnswer:
["1",1]}];
$(document).ready(function() {
function changeQuestion() {
$("#radios").empty();
for( answers in allQuestions[i].answer) {
var radioBtn = $('<input type="radio" class="radios" name="btnAnswers" value="'+
allQuestions[i].answer[j] + '" /><label for ="secondbtn">'
+ allQuestions[i].answer[j] + '</label>');
radioBtn.appendTo('#radios');
alert(allQuestions[i].answer[j]);
j++;
}
i++;
return true;
};
$("#nextbtn").click(function(){
changeQuestion();
});
});
iandjinitialized?