I want to do the following program: Web that asks the user for their notes and calculates the average grade for the term
To do this I thought I would store all the notes in an array, display them on the screen and then show the average.
var contadorNotas = parseInt(prompt("Introduce cuantos controles has hecho este trimestre:", 0)); // para saber el numero de prompts que han de salir
var controles = new Array(contadorNotas);
for(var i = 0; i <= contadorNotas - 1; i++){
controles[i] = parseInt(prompt("Introduce las notas"));
}
document.write("<h2>Estas son tus notas:</h2>");
document.write("<ul>")
for(var i = 0; i <= contadorNotas - 1; i++){
document.write("<li>"+controles[i]+"</li>");
}
document.write("</ul>");
That's my code, I'd like to know how to get the sum of the array numbers and then calculate the average .
Thank you.