Assignments    Calendar/Schedule    Table of Contents    Resources    |    MY Assignments    My COIN 70b Home

Martha's COIN 70b JavaScript Test Pages

Quiz Tester

1. George Washington was the first president of the United States. True False

2. Tucson is the capital of Arizona. True False

3. Guam is an island in the Caribbean. True False

4. JavaScript is easier to learn than Java. True False

5. Mhz refers to how much memory a computer has. True False

Results - OOPS, can't figure out how to write the results to the page! But, it should have showed up as an "Alert".

SCRIPT


function tester(form) {
     var percent;
     var correct = 0;    

     if (form[0].checked == true) correct++; // OR if (form.No1[0].checked == true) correct++;
     if (form[3].checked == true) correct++; // OR if (form.No2[1].checked == true) correct++;
     if (form[5].checked == true) correct++; // etc...
     if (form[6].checked == true) correct++;
     if (form[9].checked == true) correct++;

     percent = (correct / 5) * 100;

     if (percent == 100) alert("You got a " + percent + "%. Great Job!");

     if (percent < 100) alert("You got " + correct + " out of 5 correct ( " + percent + "% )");
}

RETURN