Produce JavaScript code (and any necessary HTML) that will perform the following functions:
1. Using the prompt and alert functions, invite the user to input 5 marks (integers) in the range 0-100.
2. Calculate the average (mean) of the 5 marks as a rounded integer or a floating point number.
3. If the average mark is 0-39, then display a message saying that the grade is a Fail, 40-69 is a Pass, and 70-100 is a Distinction. If the value is less than 0 or greater than 100, display a message saying that there has been an input error.