Write a function(Javascript) named mathQuiz that will take oneparameter which is an array of object literals with questions as astring and an the correct answer as a number.
The mathQuiz function should display each question in a prompt.Then, the answer typed in by the user will be compared to thecorrect answer. If the answer is correct, alert give the user onepoint and alert that they were correct. If the answer is incorrect,alert that is was incorrect with the question and correct answer.Continue until all of the questions are asked. Then report to theuser the score and the total number of questions.
Test case:
var quiz= [
{question:”What is the sum of 3 + 6?”, answer:9},
{question:”What is the sum of 1 + 7?”, answer:8},
{question:”What is the sum of 2 + 4?”, answer:6},
{question:”What is the sum of 6 + 2?”, answer:8},
{question:”What is the sum of 5 + 4?”, answer:9}
]
Expert Answer
Answer to Write a function(Javascript) named mathQuiz that will take one parameter which is an array of object literals with quest…