Jay Ross

Welcome to my personal website regarding debugging.

BMI Calculator

Enter your weight and height to calculate your BMI.

BMI Calculator Debugging

For this project, I added exception handling to a BMI calculator form on my personal website. The form asks for weight and height, then uses JavaScript to calculate the BMI.

I used the browser console to help debug the code. I added console.log() statements to check the weight, height, and BMI calculation. I also used console.error() to show errors in the console when invalid input was entered.

The code uses a try...catch statement. If the user enters zero, a negative number, or leaves a field blank, the code throws an error. The catch block displays a helpful error message on the webpage.

I tested the form with valid and invalid numbers to make sure the error handling worked correctly.