Created
November 21, 2023 09:36
-
-
Save ankitbtanna/324ea75fcd584c72328f85ebc9415768 to your computer and use it in GitHub Desktop.
Atlassian Interview Question - BMI Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculateBMI(weight, height) { | |
// Convert height from centimeters to meters | |
var heightInMeters = height / 100; | |
// Calculate BMI using the formula | |
var bmi = weight / (heightInMeters * heightInMeters); | |
// Round the BMI to two decimal places | |
return bmi.toFixed(2); | |
} | |
// Example usage: | |
var weight = 70; // in kilograms | |
var height = 175; // in centimeters | |
var bmi = calculateBMI(weight, height); | |
console.log("BMI:", bmi); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment