My program is designed to be a quiz where users have to answer questions. After answering, they will see a summary and then get the option to submit or redo the questions.
The issue arises when users choose to redo a question. Upon redoing it, the summary is displayed again but the submission prompt is missed out.
This leads to the submit function not being executed properly.
function showquestion() {
for (i = 0; i < 5; i++) {
console.log("\n" + "Question" + "(" + (i + 1) + ") " + quiz.mcqSelected[i].getQuestion() + "\n")
useranswer = parseInt(input.question("Please select your answer ")) + "\n"
answerstorage.push(useranswer);
console.log("You have selected answer:" + quiz.questionPool[i].choices[(parseInt(answerstorage[i])) - 1])
// break
}
showsummary();
}
function showsummary() {
console.log("Here are your answers:\n")
for (i = 0; i < 5; i++) {
console.log("\n" + "Question" + "(" + (i + 1) + ") " + quiz.mcqSelected[i].getQuestion() + "\n")
console.log("Answer: " + quiz.questionPool[i].choices[(parseInt(answerstorage[i])) - 1])
}
submit();
}
function submit() {
submit = parseInt(input.question("Enter 0 to submit your quiz, 1 to change your answer or any other keys to reselect category"));
if (submit == 0) {
console.log("You have submited your quiz.")
} else (submit == 1) {showquestion()}
}