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.

BMI is your weight divided by your height squared.

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 = [
  { type: "unit", label: "Weight", options: ["kg", "lbs"], unit: "kg" },
  { type: "unit", label: "Height", options: ["cm", "ft in"], unit: "m" },
  {
    type: "card",
    detail: "BMI is your weight divided by your height squared.",
  },
]

export const make = ([kg, m]) => {
  if (!kg || !m)
    return {
      type: "card",
      detail: "Add your weight and height to calculate your BMI.",
    }

  const limits = [18.5, 25, 30]
  const ranges = ["underweight", "normal weight", "overweight", "obese"]

  const msq = m * m
  const bmi = kg / msq

  let index = 0

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

  const min = limits[0] * msq
  const max = limits[1] * msq

  const detail = [
    `Your BMI is in the **${ranges[index]}** 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 }
}