Target Heart Rate Calculator
I wrote a heart rate calculator. This has been done, many, many times.
function HeartRateCalculator(resting, max) {
this.resting = resting;
this.max = max;
this.reserve = this.max - this.resting;
this.lower = (this.reserve * 0.6) + this.resting;
this.upper = (this.reserve * 0.8) + this.resting;
this.target = (this.lower + this.upper) / 2;
}
It basically looks like:
function HeartRateCalculator(resting, max) {
this.resting = resting;
this.max = max;
this.reserve = this.max - this.resting;
this.lower = (this.reserve * 0.6) + this.resting;
this.upper = (this.reserve * 0.8) + this.resting;
this.target = (this.lower + this.upper) / 2;
}
Resting:
Max: (You can calculate this here)
$(function() {
$('#calcTHR').click(function() {
var resting = parseInt($('#restingHR').val())
var max = parseInt($('#maxHR').val());
var heartRateCalculator = new HeartRateCalculator(resting, max);
var heartRateHtml = "Target Heart Rate = " + heartRateCalculator.target;
$('#results').html(heartRateHtml);
});
});
