The Body Mass Index (BMI) Calculator can be used to calculate BMI values based on height and weight. BMI is a fairly reliable indicator of body fatness for most people.
BMI = (weight) / (height * height)
Approach: BMI is a number calculated from an individual’s weight and height. To find out BMI we will take input from the user (both height and weight) which will be stored in height and weight variables for further calculation. The calculation process is simple, we will simply divide weight in kilograms by the square of the height. Now as per the BMI calculated, it will execute the respective if-else statement. We are also checking if the user is pressing submit button without entering the inputs, in that case, we are printing provide height or provide weight.
Using HTML we are giving desired structure, an option for the input, and submit button. With the help of CSS, we are beautifying our structure by giving colors and desired font, etc.
Example: In this example, we will structure in the index.html file and implement the logic in app.js file
Output: Click here to see live code output
Please Login to comment...