I have 2 arrays below and I must to display the sum, the average and to do a summary namely to display the course with the note.
tab_notes = new Array();
tab_course = new Array("Mathematics", "Statistics", "Algorithm");
My problem is my summary doesn't work, despite a supplementary loop...
tab_notes = new Array();
tab_course = new Array("Mathematics", "Statistics", "Algorithm");
function main(){
var sum = 0;
var average = 0;
for(var i = 0; i<tab_course.length; i++){
var notes = parseInt(prompt("Course " + tab_course[i] + " : "));
tab_notes.push(notes);
sum += notes;
}
average = sum / 3;
document.write("Sum is " + sum + "<br>");
document.write("Average is " + average + "<br>");
document.write("Summary : " + "<br>");
for(var i = 0; i<tab_course.length; i++){
document.write("Course " + course[i] + "<br>");
}
}
Do you have an idea please ?
<body onload="main()">
<center><h2>Exercice 4.8</h2></center>
</body>