0% found this document useful (0 votes)
4 views2 pages

Java Function SubmitQuiz

The document contains a JavaScript function called 'submitQuiz' that calculates a quiz score based on user-selected answers. It compares the selected answers to predefined correct answers and increments the score accordingly. Finally, it displays the total score in an alert message.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Java Function SubmitQuiz

The document contains a JavaScript function called 'submitQuiz' that calculates a quiz score based on user-selected answers. It compares the selected answers to predefined correct answers and increments the score accordingly. Finally, it displays the total score in an alert message.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

function submitQuiz() {

let score = 0;

// Correct answers

let answers = {

q1: "Requirements Gathering",

q2: "Understanding system needs",

q3: "Software Development Life Cycle",

q4: "System maintenance",

q5: "Collecting user needs"

};

// Check Q1

let q1 = [Link]('input[name="q1"]:checked');

if (q1 && [Link]() === answers.q1) {

score++;

// Check Q2

let q2 = [Link]('input[name="q2"]:checked');

if (q2 && [Link]() === answers.q2) {

score++;

// Check Q3
let q3 = [Link]('input[name="q3"]:checked');

if (q3 && [Link]() === answers.q3) {

score++;

// Check Q4

let q4 = [Link]('input[name="q4"]:checked');

if (q4 && [Link]() === answers.q4) {

score++;

// Check Q5

let q5 = [Link]('input[name="q5"]:checked');

if (q5 && [Link]() === answers.q5) {

score++;

alert("Your Score is: " + score + " / 5");

You might also like