Create a web page named lab3.html. You can format the page any way that you like
ID: 3550628 • Letter: C
Question
- Create a web page named lab3.html. You can format the page any way that you like. Give the page a title and heading.
- Create an external JavaScript file with the following:
-
- Create an array of at least 3 trivia questions. You can use the array from lab 2 if you like.
- Create a second array that contains the answers to the trivia questions in the same position as the questions.
- Create a score variable and initialize it to 0.
- create a function that will dothe following:
- use a for loop to loop through the first array and prompt the user to answer the trivia question.
- use a while loop to compare the answer to the correct answer in the 2nd array. As long as the answers do not match, continue to display the question and prompt for an answer. Keep a count of how many times the question is displayed. If it reaches 10, display an error alert and exit the loop.
- Calculate the points by subtracting the number of times the question was displayed from 10 and add it to the score.
- Return the score to the main script.
- create a second function that will use one parameter. This function will take in the score as the input parameter and generate a comment on their performance. For example, if the maximum score is 30 and they get 30 points, then the comment might be "Excellent job" or something similar. A score of 0 might receive a "You need to try harder", etc. Return the comment to main script.
- Be sure to link the external JavaScript file to the web page.
- In the web page, after the heading, call the function to display and score the trivia quiz.
- Then call the second function and pass the score to it. Write out the returned comment to the page.
Explanation / Answer
Deadline for this ?
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.