Here is the JavaScript code to solve the problem:
<script>
// Get the grades from the prompt
var grade1 = parseInt(prompt("Enter grade 1"));
var grade2 = parseInt(prompt("Enter grade 2"));
var grade3 = parseInt(prompt("Enter grade 3"));
var grade4 = parseInt(prompt("Enter grade 4"));
// Add all the grades
var total = grade1 + grade2 + grade3 + grade4;
// Calculate the final grade
var finalGrade = total/4;
// Display the final grade
alert("The final grade is " + finalGrade);
</script>