To effectively burn fat, it's important to exercise within a specific heart rate zone. This zone, often referred to as the "fat-burning zone," typically falls between 60% and 70% of your maximum heart rate. Calculating this range helps you optimize your workouts for fat loss.
function calculateFatBurningHeartRate() {
var age = document.getElementById("age").value;
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(age) || age = 120) {
resultDiv.innerHTML = "Please enter a valid age between 1 and 119.";
return;
}
// Estimate Maximum Heart Rate using the Tanaka formula (208 – (0.7 * age))
var maxHeartRate = 208 – (0.7 * age);
// Calculate the Fat Burning Zone (60% to 70% of Maximum Heart Rate)
var lowerFatBurnRate = maxHeartRate * 0.60;
var upperFatBurnRate = maxHeartRate * 0.70;
resultDiv.innerHTML =
"Based on your age, your estimated maximum heart rate is: " + Math.round(maxHeartRate) + " bpm" +
"Your target fat burning heart rate zone is approximately:" +
"" + Math.round(lowerFatBurnRate) + " bpm to " + Math.round(upperFatBurnRate) + " bpm" +
"Aim to keep your heart rate within this range during your workout for optimal fat burning.";
}
.calculator-container {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 400px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.calculator-container p {
line-height: 1.6;
color: #555;
margin-bottom: 15px;
}
.input-section {
margin-bottom: 15px;
}
.input-section label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #444;
}
.input-section input[type="number"] {
width: calc(100% – 22px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.calculator-container button {
display: block;
width: 100%;
padding: 12px 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #45a049;
}
.result-section {
margin-top: 20px;
padding: 15px;
border: 1px dashed #ccc;
background-color: #fff;
border-radius: 4px;
}
.result-section p {
margin-bottom: 8px;
color: #333;
}
.result-section strong {
color: #4CAF50;
}
.error {
color: #f44336;
font-weight: bold;
}