Unless the requirement is to remember all data for all students and then dump all the results out at the end, you don't really need to change much.
You could just put a for
loop around *ALL* of the existing code.
Maybe add a prompt for student name at the top of the loop and then dump out the name as part of printing their average.
for ( var st = 1; st <= 4; ++st )
var student = prompt("Enter the name of student #" + st);
... your existing code ...
// Write result to page...NEXT LINE IS CHANGED:
document.write("<br>" + student + "'s average is "+average+". "
+ student + " hase a "+lGrade + "<hr/>");
Why work harder?
Now...if you have to remember *ALL* the data and write it all out at the end you'll have to do a bit more work.