Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnas AlHariri
8,776 PointsMy solution for the Quiz Program homework. I need a teacher to look at the code and advice me if it can be better.
//2D Array sub arrays that contain Questions and Answers Declaration. var questionsList = [ ["1 + 0 = ","1"], ["1 + 1 = ","2"], ["2 + 1 = ","3"], ["3 + 1 = ","4"], ["4 + 1 = ","5"], ["5 + 1 = ","6"], ];
//Declaring an array to obtain the Correct answered Questions to display them at the end of the program. var listOfCorrectAnsweredQuestions = [];
//Declaring an array to obtain the incorrect answered Questions to display them at the end of the program. var listOfINCorrectAnsweredQuestions = [];
//Print Function. function print( _parameter ){ document.write(_parameter); }
//Header for the correct answered questions' list. function correctHeaderDisplay( correctArrayList ){ print("<h1>You answered the following " + correctArrayList.length + " Questions correctly:</h1>"); }
//Header for the Incorrect answered questions' list. function incorrectHeader ( wrongArrayList ){ print("<h1>You answered the following " + wrongArrayList.length + " Questions wrong:</h1>"); }
//Creating a FUNCTION to ask the questions to the user. And Saving a list of correct answers in general scope array, and saving a list of wrong answers in a general scope array. function askQuestionList(QuestionsListArray){ var userAnswer; for (var i = 0; i < QuestionsListArray.length;i++){ userAnswer = prompt(QuestionsListArray[i][0]); userAnswer = userAnswer.toUpperCase(); if (userAnswer === (QuestionsListArray[i][1]).toUpperCase()){ listOfCorrectAnsweredQuestions.push(QuestionsListArray[i][0] + " " + QuestionsListArray[i][1]); }else{ listOfINCorrectAnsweredQuestions.push(QuestionsListArray[i][0] + " " + userAnswer); } } }
//Creating a FUNCTION to display the Count of the Correct Answers and list them. function displayAndListCorrectAnswers( CorrectAnswersList ){ correctHeaderDisplay(CorrectAnswersList); var listCorrectOrganized = "<ol>"; for(var i = 0; i < CorrectAnswersList.length; i++){ listCorrectOrganized += "<li>" + CorrectAnswersList[i] + "</li>"; }
listCorrectOrganized += "</ol>";
print(listCorrectOrganized);
}
//Creating a FUNCTION to display the Count of the INCorrect Answers and list them. function displayAndListINCorrectAnswers( INCorrectAnswersList ){ incorrectHeader(INCorrectAnswersList); var listINCorrectOrganized = "<ol>"; for(var i = 0; i < INCorrectAnswersList.length; i++){ listINCorrectOrganized += "<li>" + INCorrectAnswersList[i] + "</li>"; }
listINCorrectOrganized += "</ol>";
print(listINCorrectOrganized);
}
//The Beginning of Processing the program by calling the Functions.
//Asking the questions. askQuestionList(questionsList);
//Calling the function to display correct answers count and list them. displayAndListCorrectAnswers(listOfCorrectAnsweredQuestions);
//Calling the function to display incorrect answers count and list them. displayAndListINCorrectAnswers(listOfINCorrectAnsweredQuestions);
1 Answer
Steven Parker
231,275 PointsYou only get individual evaluations by teachers/mentors in the Techdegree program.
And if you were in that program, you would have been given a way to submit your assignments other than the forum.