-
Notifications
You must be signed in to change notification settings - Fork 0
/
loss.js
21 lines (16 loc) · 913 Bytes
/
loss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function calculateCalorieGoal() {
var currentWeight = parseFloat(document.getElementById("currentWeight").value);
var targetWeight = parseFloat(document.getElementById("targetWeight").value);
var weeks = parseInt(document.getElementById("weeks").value);
if (isNaN(currentWeight) || isNaN(targetWeight) || isNaN(weeks) || weeks <= 0) {
alert("Please enter valid current weight, target weight, and number of weeks.");
return;
}
var weightDifference = currentWeight - targetWeight;
var weeklyCalorieDeficit = weightDifference * 7700 / weeks;
var calorieGoal = calculateDailyCalorieExpenditure(currentWeight) - weeklyCalorieDeficit;
document.getElementById("result").innerHTML = "Your daily calorie goal for weight loss is approximately " + calorieGoal.toFixed(0) + " calories.";
}
function calculateDailyCalorieExpenditure(weight) {
return weight * 24;
}