This is a small unit-normalization and category-boundary example. It takes a person’s height and weight in metric units, computes Body Mass Index, and reports the adult BMI category.
It is intended to demonstrate transparent calculation and boundary checks. It is not a health assessment.
The input gives weight in kilograms and height in centimeters. The program converts centimeters to meters, then applies the standard BMI calculation: weight divided by height squared.
After computing the value, it maps the number to a category: underweight, normal, overweight, or obese. It also calculates the weight range that would correspond to a normal BMI range at the same height.
The output does more than print a BMI number. It also shows the category and a height-specific healthy-weight range. That makes the answer easier to interpret for readers who do not remember the category thresholds.
The trust gate verifies that height and weight are positive, the emitted category follows from the computed BMI, the healthy-weight range is ordered, and the input weight falls inside that range for the normal category. This catches mistakes in unit conversion or threshold handling.
From the repository root:
node examples/bmi.js