I'm working on this assignment where basically I'm gathering data from users to input their student's grades. I was prompted to store the student names and 4 of each student's grades and average them out in the end. I have hit a hole and unsure how to get these values to add them up and average them.
Here's what I have written so far:
let lab1 = [];
let lab2 = [];
let lab3 = [];
let lab4 = [];
let stuName = [];
let grades = [];
let grade = 0;
let tGrade = 0;
do {
let tName = prompt("Enter Student Name: ");
stuName[stuName.length] = tName;
//prompting user for a grade and converting it LAB1
tGrade = prompt("Input Grade for lab 1: ");
grade = parseInt(tGrade);
//If grade is valid, then add it to the array
if (grade >= 0 && grade <= 100) {
//info stored in the array
lab1[lab1.length] = grade;
}
//prompting user for a grade and converting it LAB2
tGrade = prompt("Input Grade for lab 2: ");
grade = parseInt(tGrade);
//If grade is valid, then add it to the array
if (grade >= 0 && grade <= 100) {
//info stored in the array
lab2[lab2.length] = grade;
}
//prompting user for a grade and converting it LAB3
tGrade = prompt("Input Grade for lab 3: ");
grade = parseInt(tGrade);
//If grade is valid, then add it to the array
if (grade >= 0 && grade <= 100) {
//info stored in the array
lab3[lab3.length] = grade;
}
//prompting user for a grade and converting it LAB4
tGrade = prompt("Input Grade for lab 4: ");
grade = parseInt(tGrade);
//If grade is valid, then add it to the array
if (grade >= 0 && grade <= 100) {
//info stored in the array
lab4[lab4.length] = grade;
}
//giving user option to end inputs
tGrade = prompt("Do you want continue? -1 to exit: ", "-1");
grade = parseInt(tGrade);
} while (grade != -1); //loop escape