I'm trying to run a small program that loads questions onto an object array based on what the user types in an input text box. This is how the HTML looks. https://i.sstatic.net/BNdki.png
So far i've done this. i want the loop to repeat everytime the "add question" button is clicked (that button executes the function "AddQuestion"), so i added the "loop" variable, and added a for loop to show me the question's titles. but it doesn't seem to work...
class questions {
constructor(question, cat, ans1, ans2, ans3, ans4) {
this.question = question;
this.cat = cat;
this.ans = ans1;
this.ans2 = ans2;
this.ans3 = ans3;
this.ans4 = ans4;
}
}
loop = 0
function AddQuestions()
{
loop++;
var question = new Array(10);
title = document.getElementById("question").value;
category = document.getElementById("category").value;
answ1 = document.getElementById("ans1").value;
answ2 = document.getElementById("ans2").value;
answ3 = document.getElementById("ans3").value;
answ4 = document.getElementById("ans4").value;
question[loop] = new questions (title, category, ans1, ans2,
ans3, ans4);
console.log(question[loop].question);
for ( i = 0 < question.length; i++;) {
console.log(question[i].question);
}
}