The script in this version is in the body.

The script is next - then there is some HTML code.

I will write some code to explain that \n will mean a new line while \r means a carriage control. Essentially if you want to use a character that usually has special meaning you can use it preceeded by a backslash. Note the code that I used above in the second document.write to get the quotes around The grade is.
Note to calculate another grade, you will need to refresh or reload depending on your browser.

It should be notes that math follows the order of operation which means:
  1. Operations in parenthesis are resolved - with nested parenthesis, inner are resolved first
  2. Working from left to right multiplication (*), division(/) and modulus (%) are resolved next.
  3. Working from left to right addition (+) and subtraction (-) are handled next.