I am trying to add to the loop so that the user is prompted if they would like to make another entry. If yes, loop again, if no, exit the loop.
I have tried using a boolean saying if they choose yes, the students = true, and the loop continues. A simplified version:
<!DOCTYPE html>
<html>
<body>
<script>
//Declare Variable
var students = true;
var total;
var message = "";
//Process
while(students = true){
name = prompt("Enter the student name:");
while(name == ""){
name = prompt("Invalid entry, please enter the student name:");
}
students = (prompt("Add another student? Enter Y or N")).toUpperCase();
while(students == "" || students != "Y" && students != "N"){
students = prompt("Invalid entry, would you like to add another student? Enter Y or N:").toUpperCase();
}
if(students == "Y"){
students = true;
}
else if(students == "N"){
students = false;
}
message+= "\nName: "+name+"\nMidterm grade: "+midterm+"\nFinal exam grade: "+final+"\nHomework grade: "+homework+"\nAttendance grade: "+attendance+"\nTotal points: "+total+"\nPercentage: "+percent+"\nLetter grade: "+letterGrade+"\n";
}
//Output
if(students = false){
alert("Student Grades"+message);
}
</script>
</body>
</html>