Grade Calculator
Languages Used:
HTML
CSS
JavaScript
PHP
If you would like to visit the site, please click here.
This little project was an assignment for Web Communications 3. The point of the task was to develop a website using just JavaScript that can calculate the letter grade and percentage of any assignment. I decided to take this project one step further by choosing to add a PHP backup if the user was not using JavaScript or JavaScript failed for some reason.
The problems & My solutions:
The first problem I ran into was keeping the JavaScript from ever needing to repeat itself. The answer was relatively easy; a JavaScript function was all I needed, running the math through the function than having JavaScript select the correct grade was simple after that. The next problem I ran into was how to deal with someone putting their grad as a number higher than the total possible grades; this solution again was easy to solve by adding a single line of code to check if the users’ marks were less than or equal to the total marks for the assignment.
One of the two most significant problems I ran into was making sure the script would not run until both numbers had been put into their respective fields. Now that I solved the problem it seems trivial, but as I was initially working on how I wanted to deal with it, I struggled. The solution, of course, is an if statement asking if both fields had been filled in. The final major issue was something I had not thought of when starting the project due to of how JavaScript works it takes the field inputs as a string so I ended up getting weird grades that didn’t match what they should. The solution was simple, but because I hadn’t thought about it before starting, I struggled to find the answer at first, the solution was adding valueAsNumber when calling the fields.
Overall I feel this project was an excellent learning process; this was the first major JavaScript project that had been done, so I found that I struggled a bit at the start. This project was still fun to make and I used it occasionally to test what kind of grade I might get on a project while waiting for grades to come in fully.