Body Fat Calculator

Please fill in all required fields.

"; pdfBtn.style.display = "none"; return; } let bodyFat = 0; if (gender === "male") { bodyFat = 86.010 * Math.log10(waist - neck) - 70.041 * Math.log10(height) + 36.76; } else { bodyFat = 163.205 * Math.log10(waist + hip - neck) - 97.684 * Math.log10(height) - 78.387; } bodyFat = Math.round(bodyFat * 10) / 10; const category = getFitnessCategory(gender, bodyFat); resultDiv.innerHTML = `

Estimated Body Fat: ${bodyFat}%

Fitness Category: ${category}

`; pdfBtn.style.display = "block"; }; function getFitnessCategory(gender, bf) { if (gender === "male") { if (bf < 6) return "Essential Fat"; if (bf <= 13) return "Athlete"; if (bf <= 17) return "Fitness"; if (bf <= 24) return "Average"; return "Obese"; } else { if (bf < 14) return "Essential Fat"; if (bf <= 20) return "Athlete"; if (bf <= 24) return "Fitness"; if (bf <= 31) return "Average"; return "Obese"; } } window.downloadBodyFatPDF = function () { const gender = genderSelect.value; const age = document.getElementById("age").value; const height = document.getElementById("height").value; const neck = document.getElementById("neck").value; const waist = document.getElementById("waist").value; const hip = document.getElementById("hip").value; let bodyFat = 0; if (gender === "male") { bodyFat = 86.010 * Math.log10(waist - neck) - 70.041 * Math.log10(height) + 36.76; } else { bodyFat = 163.205 * Math.log10(parseFloat(waist) + parseFloat(hip) - parseFloat(neck)) - 97.684 * Math.log10(height) - 78.387; } bodyFat = Math.round(bodyFat * 10) / 10; const category = getFitnessCategory(gender, bodyFat); const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(18); doc.text("Body Fat Calculator Report", 14, 20); doc.setFontSize(12); doc.text(`Gender: ${gender}`, 14, 35); doc.text(`Age: ${age}`, 14, 45); doc.text(`Height: ${height} in`, 14, 55); doc.text(`Neck: ${neck} in`, 14, 65); doc.text(`Waist: ${waist} in`, 14, 75); if (gender === "female") doc.text(`Hip: ${hip} in`, 14, 85); doc.text(`Estimated Body Fat: ${bodyFat}%`, 14, gender === "male" ? 85 : 95); doc.text(`Fitness Category: ${category}`, 14, gender === "male" ? 95 : 105); doc.save("body-fat-calculation.pdf"); }; });
Scroll to Top