TDEE Calculator | Legion
if (isNaN(age) || isNaN(weight) || isNaN(height) || isNaN(activity)) { alert("Please fill in all fields correctly."); return; }
// Calculate BMR using Mifflin-St Jeor Equation let bmr; if (gender === "male") { bmr = 10 * weight + 6.25 * height - 5 * age + 5; } else { bmr = 10 * weight + 6.25 * height - 5 * age - 161; }
// Calculate TDEE const tdee = bmr * activity;
// Display result const resultDiv = document.getElementById("result"); resultDiv.style.display = "block"; resultDiv.innerHTML = `
Your TDEE is: ${tdee.toFixed(2)} calories/day
This is the estimated number of calories you burn daily, including activity level.
`;
}