//script.js


var score = 0;  //this will store how many of the questions they got right.
var wrong = 0;  //this will store the wrong answers


function validate(form)	{


var answersAndObjects = new Array();  //This array stores the answers and references to the questions
answersAndObjects[0] = ["pump", form.espressomachine];
answersAndObjects[1] = ["grinder", form.grinder];
answersAndObjects[2] = ["conical", form.burrs];
answersAndObjects[3] = ["beans", form.beans];
answersAndObjects[4] = ["extraction", form.extraction];
answersAndObjects[5] = ["coarse", form.course];
answersAndObjects[6] = ["packing", form.packing];
answersAndObjects[7] = ["milk", form.milk];
answersAndObjects[8] = ["pour", form.pour];
answersAndObjects[9] = ["portafilter", form.portafilter];


	for (var i=0; i < answersAndObjects.length; i++)	{
	
	var currQuestion = answersAndObjects[i][1];
	
	for	(j = 0; j < currQuestion.length; j++) {
		/*currQuestion now holds references to the questions and is looping through them */
		
		if	(currQuestion[j].checked && currQuestion[j].value == answersAndObjects[i][0])	{
			/* this loops through the references makes sure their checked and checks the array to see if the answer is correct */
			score++;
			break;
		}	else	{
				wrong++;
				break;
			}
			
	}
	}

document.getElementById('answer').innerHTML = 'you got ' + score + ' answers correct';

}