function getScore(form) {
  var score = 0;
  var currElt;
  var currChoice;
  var allDone = 0; // variable to see  if all questions have been answered 
  var questionIncorrect= new Array(numQues); // array to store the incorrect questions
	
	for (i=0; i<numQues; i++) {
    	currElt = i*numChoices

    		for (j=0; j<numChoices; j++) {
      		currChoice = form.elements[currElt + j];

      			if (currChoice.checked) {
				allDone++; // increment the questions done counter

        			if (currChoice.value == answers[i]) {
          			score++;
          			questionIncorrect[i] = ""; // if the answer is correct, put a place holder in the array to prevent undefined
				break;
        			}

				else{   <!-- if the answer is not correct: -->
				questionIncorrect[i]= i+1; // write the number of the incorrect question into the array
				}
      

			}

			
    		}  

	}

		// check to see if all the questions have been done 
	if(allDone != numQues){
		alert("You have not answered all the questions")
	return;
	}

  score = Math.round(score/numQues*100);
  form.percentage.value = score + "%"; // prints the score

  //build the string for the correct answers
  var correctAnswers = "";

  	for (i=1; i<=numQues; i++) {
    	correctAnswers += i + ". " + answers[i-1] + "\r\n";
  	}

  //build the string for the incorrect questions 
  var incorrectAnswers = "";

  	for (i=1; i<=numQues; i++) {
    	incorrectAnswers  += questionIncorrect[i-1] +" ";
  	}	

  form.solutions.value = correctAnswers; // prints the answers 
  form.incorrect.value = incorrectAnswers; // prints the incorrect answers

}