here’s the whole script. there seems to be a problem in the first if-then statement of the function, because it always says that you get 0 correct. i call upon this with quiz(rageQuestion, rageAnswer) or quiz(f50Question, f50Answer), or, you get the point. just say so if the attached file would be helpful. if someone would please take the time to point out my error it would be greatly appreciated.
var rageQuestion = new Array(“In what year was Rage Against the Machine’s album ‘The Battle of Los Angeles’ released?”, “How many band members were in Rage Against the Machine?”,
“Tom Morello plays what instrument?”);
var rageAnswer = new Array(“1999”, “4”, “guitar”);
var f50Question = new Array(“What is the Ferrari F-50’s top speed? (in mph)”, “In what year was the F-50 made?”,
“How much horsepower does a Ferrari F-50 have?”);
var f50Answer = new Array(“202”, “1995”, “520”);
var chimpQuestion = new Array(“On which continent do chimpanzees live in the wild?”, “True or false – in the United States, over 1400 chimps are used for biomedical research”,
“To the nearest one hundredth, what percent chimpanzees are genetically identical to humans?”);
var chimpAnswer = new Array(“africa”, “true”, “98.76”);
var steadyQ = new Array();
var correct=0;
var response=new Array(” Better luck next time!”, ” At least you got one!”, ” Not bad!”, ” You know a lot!”);
function quiz(question, answer, tried)
{
for(var loop=0; loop<3; loop++)
{
steadyQ = prompt(question[loop], “”);
if(steadyQ[loop]==answer[loop])
{
correct++;
}
}
alert(“You got ” + correct + ” correct! ” + response[correct]);
if(correct!=3)
{
var answerKey=confirm(“Do you want to view the correct answers?”);
if(answerKey==1)
{
for(var looper=0; looper<3; looper++)
{
alert(answer[looper]);
}
}
}
}