Quiz Questions And Answers
Quiz Questions
< html > < body >
< script >
function returnScore() {
alert("Your score is " + getScore() + "/10");
}
< / script >
< form id = "form1" >
< li >
< h3 > How many letters are there in "JSX" ? < / h3 >
< input type = "radio" name = "question8" value = "A" > 2 < br >
< input type = "radio" name = "question8" value = "B" > 1 < br >
< input type = "radio" name = "question8" value = "C" > 3 < br >
< input type = "radio" name = "question8" value = "D" > 4 < br >
< / li >
< li >
< h3 > How many letters are there in "JS" ? < / h3 >
< input type = "radio" name = "question9" value = "A" > 2 < br >
< input type = "radio" name = "question9" value = "B" > 1 < br >
< input type = "radio" name = "question9" value = "C" > 3 < br >
< input type = "radio" name = "question9" value = "D" > 4 < br >
< / li >
< / form >
< button onclick = "javascript: returnScore()" > View Results < / button >
< script type = "text/javascript" >
var userInput = [];
var answers = []
answers[0] = "B";
answers[1] = "C";
answers[2] = "A";
answers[3] = "C";
answers[4] = "D";
answers[5] = "D";
answers[6] = "D";
answers[7] = "D";
answers[8] = "C";
answers[9] = "A";
function getScore() {
var score = 0;
var numQuestions = 10;
var form = document.getElementById('form1');
userInput[8] = form1.question8.value;
userInput[9] = form1.question9.value;
for (var i = 0; i < numQuestions; i++) {
if (userInput[i] == answers[i]) {
score += 1;
} else {
score += 0;
}
}
return score;
}
< / script >
< / body > < / html >
No comments:
Post a Comment