Public
Edited
Jun 21, 2024
Insert cell
Insert cell
Insert cell
kcal_per_day = 300 // Calories burned per day in the gym
Insert cell
// Cell 3: Start Date Picker
//start_date = Inputs.date({label: "Start Date", value: new Date()})
Insert cell
// Cell 4: End Date Picker
//end_date = Inputs.date({label: "End Date", value: new Date()})
Insert cell
// // Cell 5: Calculate Number of Days Between Dates
// days = {
// const diffTime = Math.abs(end_date - start_date);
// const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + 1; // Adding 1 to include both start and end dates
// return diffDays;
// }
Insert cell
days = 4 // Number of days
Insert cell
inclination = 11 // Inclination of the treadmill in degrees
Insert cell
function weight_loss_calculator_gym(kcal_per_day, days, inclination) {
// Inclination adjustment factor (arbitrary example values for the sake of illustration)
let inclination_factor = inclination > 0 ? 1 + inclination * 0.01 : 1;

let adjusted_kcal_per_day = kcal_per_day * inclination_factor;
let total_kcal_burned = adjusted_kcal_per_day * days;
let weight_loss = total_kcal_burned / 3500; // 1 pound of fat = 3500 calories

return weight_loss;
}
Insert cell
estimated_weight_loss = weight_loss_calculator_gym(
kcal_per_day,
days,
inclination
)
Insert cell
md`**Estimated weight loss over ${days} days:** ${estimated_weight_loss.toFixed(
2
)} pounds`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more