Could someone explain why my loop is only showing the last object of my array? Because I would like to output all the responses for my quiz Thank you!
var allQuestions = [
{
question: "Welk kerstnummer draai jij grijs tijdens de feestdagen?",
responses: [{
text: 'Feliz Navidad',
value: 10
},
{
text: 'Baby, Its Cold Outside',
value: 6
},
var currentQuestion = 0;
var question;
var responses;
var questions = document.getElementById("question");
var quizForm = document.getElementById("choiceList");
function showQuestion() {
question = allQuestions[currentQuestion].question;
// choice = allQuestions[answers].responses.length;
questions.innerHTML = "<p>" + question + "</p>";
for (var i = 0; i < allQuestions[currentQuestion].responses.length; i++) {
responses = allQuestions[currentQuestion].responses[i].text;
quizForm.innerHTML = "<li>" + responses + "</li>";
}
}
showQuestion();
quizForm.innerHTML += "<li>" + responses + "</li>";