Skip to content

Instantly share code, notes, and snippets.

@ankitbtanna
Created November 21, 2023 09:36
Show Gist options
  • Save ankitbtanna/324ea75fcd584c72328f85ebc9415768 to your computer and use it in GitHub Desktop.
Save ankitbtanna/324ea75fcd584c72328f85ebc9415768 to your computer and use it in GitHub Desktop.
Atlassian Interview Question - BMI Calculator
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