DEV Community

Cover image for How I Built a Height Predictor Calculator Using JavaScript
Krishna Sapkota
Krishna Sapkota

Posted on

How I Built a Height Predictor Calculator Using JavaScript

I Built a Height Predictor Calculator Using JavaScript

Most calculators on the internet are either too simple or too confusing. I wanted to build something that was both useful and scientifically based, so I built a Height Predictor Calculator using JavaScript that estimates adult height using multiple methods.

The Idea

One day I was wondering: “How tall will I be?”

Instead of building a simple calculator, I created one that uses:

  • Mid-Parental Method
  • Khamis–Roche Method
  • Bone Age Method

Method 1 – Mid-Parental Height

Boys = (Father height + Mother height + 13) / 2

Girls = (Father height + Mother height - 13) / 2

This gives a baseline estimate.

function midParental(father, mother, sex) {
  return sex === "male"
    ? (father + mother + 13) / 2
    : (father + mother - 13) / 2;
}

Enter fullscreen mode Exit fullscreen mode

Method 2 – Khamis–Roche

Uses:

  • Age
  • Height
  • Weight
  • Parents height

Regression-based formula with blending for realistic results.

function khamisRoche(age, height, weight, father, mother) {
  const mid = (father + mother) / 2;
  let regression = /* coefficients logic */;
  return (regression * 0.65) + (mid * 0.35);
}
Enter fullscreen mode Exit fullscreen mode

Method 3 – Bone Age

Adult Height = Current Height / Maturity Ratio

Accounts for growth tempo.

function boneAge(height, ratio) {
  return height / ratio;
}
Enter fullscreen mode Exit fullscreen mode

Key Learnings

  • Always show a range, not exact number
  • Blend formulas for realistic output
  • UX matters more than math

Final Thoughts

Building tools like this is one of the best ways to learn JavaScript.

Try building your own calculators — they are simple, useful, and great for learning.

Try the tool here

Top comments (0)