DEV Community

Discussion on: Daily Challenge #57 - BMI Calculator

Collapse
 
willsmart profile image
willsmart

Fair point Craig, in this case it turns out to be a bunch slower due to the complexity in indexFromBmi.
I just figured it was worth posting as an alternative approach as there are problems where luts are gold. In this case apparently not.

I'd say that here it's best to just use

function bmiLabel(weight, height) {
  const bmi = weight / height ** 2;
  return bmi <= 18.5 ? 'Underweight' : bmi <= 25 ? 'Normal' : bmi <= 30 ? 'Overweight' : 'Obese';
}

and be done with it.