Body Mass Index calculator

Body mass index, or BMI, is a simple indicator that can be used to see whether your weight is in the healthy range. The calculation of BMI combines your height and weight to help predict the risk of developing disease.

Face with waiting expression Nothing to see yet!

Loading takeymakey...
TakeyMakey code
Want this tool to do something else? Edit the code below and make it do whatever you want.
export const take = [
  { label: "Weight", type: "unit", options: ["kg", "lbs"], unit: "kg" },
  { label: "Height", type: "unit", options: ["cm", "ft in"], unit: "cm" },
]

export const make = ([kg, cm]) => {
  if (!kg || !cm) return "Add your weight and height to calculate your BMI."

  const bmi = kg / Math.pow(cm / 100, 2)
  const limits = [18.5, 25, 30]
  const ranges = ["underweight", "normal weight", "overweight", "obese"]

  let index = 0

  while (bmi > limits[index]) index++

  const min = limits[0] * Math.pow(cm / 100, 2)
  const max = limits[1] * Math.pow(cm / 100, 2)

  const detail = [
    `Your BMI is in the <strong>${ranges[index]}</strong> range.`,
    `<br>For someone of your height, the normal weight range is between`,
    `${+min.toFixed(1)}${+max.toFixed(1)}kg.`,
  ].join(" ")

  return {
    type: "card",
    value: +bmi.toFixed(1),
    detail,
  }
}