In my program I have a prompt first that asks for the user to enter a grade and then a while loop which says while the grade does not equal -1 to ask for the grade again. I have an else statement with a counter called “count” incrementing by one afterwards and then printing the grade within a table. The program then asks for the grade again until a -1 is pressed.
Here is my code.
var count = 0;
var total = 0;
var grade;
var avg = 0;
grade = prompt('Enter grade(-1 to stop)');
while (grade != -1) {
grade = prompt('Enter grade again');
else
count++;
document.write('<tr>');
document.write('<td>Grade ' + count '</td>');
document.write('<td width="50">' + grade '</td>');
document.write('</tr>');
grade = prompt('Enter grade(-1 to stop)');
total = total + grade;
document.write('</table>');
avg = total / count;
document.write('Semester Average: ' + avg);
}
When a negative 1 is entered it should add of the total number of all grades, and then calculate an average by dividing the count by the total. This will not run. Any tips would be appreciated.