DEV Community

loading...

Design a BMI Calculator using JavaScript

Ahtsham Ajus
Beginner. Starting my journey of Web Development.
・1 min read

The Body Mass Index (BMI) Calculator can be used to calculate BMI values based on their height and weight. BMI is a fairly reliable indicator of body fatness for most people.

Formula:

BMI = (weight) / (height * height)

Here's JavaScript code

 function BMI(weight, height) {
     return(weight / (height * height));
 }

 let bmiResult = BMI(57, 1.73736);
 console.log(bmiResult);
Enter fullscreen mode Exit fullscreen mode

Alt Text

Discussion (7)

Collapse
inhuofficial profile image
InHuOfficial

173.736m...that is a very tall person! 😜🤣

Especially at 57kg, they need to lose some weight!

Collapse
link2twenty profile image
Andrew Bone

0.0018884053362648637 BMI, I think they need to put some on...

Collapse
inhuofficial profile image
InHuOfficial • Edited

I was kidding 😋 At 57kg very few people should need to lose weight!

I was trying to work out how thin they would have to be to be 173m tall and 57kg but I couldn't quite get it right, I think it is about 0.57cm wide! 🤣

Thread Thread
ahtshamajus profile image
Ahtsham Ajus Author • Edited

no sir 1.73736m and 173.736cm

Thread Thread
link2twenty profile image
Andrew Bone • Edited

Let's do some maths 😁

985 kg/m3
weight = height(m) * width(m) * depth(m) * 985
57 = 173 * 0.41 * depth * 985
57 / 985 = 173 * 0.41 * depth
0.0579 (4dp) = 173 * 0.41 * depth
0.0579 = 70.93 * depth
depth = 8.1629775835330607641336528972226e-4m
depth = 0.0816cm (4dp)
Enter fullscreen mode Exit fullscreen mode

This is presuming average human density and a 'normal' shoulder width of 41cm.

😅

Thread Thread
inhuofficial profile image
InHuOfficial

Aww now our thread makes no sense as OP has fixed it 🤣🤣

Love the fact you took the time to work it out properly!

Collapse
ahtshamajus profile image
Ahtsham Ajus Author

lets see bro