How to Calculate Hear Rate

Heart Rate Calculator

Understanding your heart rate is crucial for monitoring your fitness levels and overall cardiovascular health. Heart rate, measured in beats per minute (bpm), indicates how many times your heart beats within that timeframe. This calculator helps you estimate your target heart rate zones for exercise.

Your Target Heart Rate Zones:

Maximum Heart Rate (MHR): bpm

Moderate Intensity Zone (50-70% of MHR): bpm

Vigorous Intensity Zone (70-85% of MHR): bpm

function calculateHeartRateZones() { var age = parseFloat(document.getElementById("age").value); var restingHeartRate = parseFloat(document.getElementById("restingHeartRate").value); var maxHeartRateElement = document.getElementById("maxHeartRate"); var moderateZoneElement = document.getElementById("moderateZone"); var vigorousZoneElement = document.getElementById("vigorousZone"); // Clear previous results maxHeartRateElement.textContent = ""; moderateZoneElement.textContent = ""; vigorousZoneElement.textContent = ""; // Input validation if (isNaN(age) || age = 120) { alert("Please enter a valid age."); return; } if (isNaN(restingHeartRate) || restingHeartRate = 250) { alert("Please enter a valid resting heart rate."); return; } // Calculate Maximum Heart Rate (using the common Karvonen formula approximation) var maxHeartRate = 220 – age; maxHeartRateElement.textContent = maxHeartRate.toFixed(0); // Calculate Moderate Intensity Zone (50-70% of MHR) var moderateLowerBound = maxHeartRate * 0.50; var moderateUpperBound = maxHeartRate * 0.70; moderateZoneElement.textContent = moderateLowerBound.toFixed(0) + " – " + moderateUpperBound.toFixed(0); // Calculate Vigorous Intensity Zone (70-85% of MHR) var vigorousLowerBound = maxHeartRate * 0.70; var vigorousUpperBound = maxHeartRate * 0.85; vigorousZoneElement.textContent = vigorousLowerBound.toFixed(0) + " – " + vigorousUpperBound.toFixed(0); } .heart-rate-calculator { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 500px; margin: 20px auto; background-color: #f9f9f9; } .heart-rate-calculator h2 { text-align: center; color: #333; margin-bottom: 20px; } .heart-rate-calculator p { line-height: 1.6; color: #555; margin-bottom: 15px; } .input-section { margin-bottom: 15px; } .input-section label { display: block; margin-bottom: 5px; font-weight: bold; color: #444; } .input-section input[type="number"] { width: calc(100% – 22px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; /* Include padding and border in the element's total width and height */ } .heart-rate-calculator button { background-color: #4CAF50; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; width: 100%; margin-top: 10px; transition: background-color 0.3s ease; } .heart-rate-calculator button:hover { background-color: #45a049; } #result { margin-top: 25px; padding-top: 15px; border-top: 1px dashed #eee; } #result h3 { color: #333; margin-bottom: 15px; } #result p { margin-bottom: 8px; color: #666; } #result span { font-weight: bold; color: #007bff; /* A distinct color for the results */ }

Leave a Comment