Last active
January 25, 2019 19:15
-
-
Save Marknel/40d5c9bf9f014e7a234a to your computer and use it in GitHub Desktop.
Calorie Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inputs | |
var sex = "male" // "male" || "female" | |
var age = 24 // Age in years | |
var height = 172 // Height in centimeters | |
var weight = 75 // Weight in kilograms | |
var activity_scalar = 1.2 // 1 -> 1.9 (1 being motionless, 1.9 being hugely active) | |
calculateBMR = function(sex, age, weight, height) { | |
var bMR = 0; | |
bMR = (9.99 * weight) + (6.25 * height) - (4.92 * age); | |
if (sex == "male") { | |
bMR += 5 | |
} else { | |
bMR -= 161 | |
} | |
return bMR | |
} | |
calculateTDEE = function(bMR, activity_scalar) { | |
return bMR * activity_scalar; | |
} | |
calculateCalories = function(sex, age, weight, height, activity_scalar) { | |
var bMR = calculateBMR(sex, age, weight, height); | |
return calculateTDEE(bMR, activity_scalar); | |
} | |
// Activity Scalar Explanation | |
// | |
// 1.0 - Basal Metabolic Rate (energy required to be alive - no exercise whatsoever) | |
// 1.2 - Little to no exercise (walking around the house) | |
// 1.375 - Exercising 3 times per week (15-30 minutes each time) | |
// 1.4187 - Exercising 4 times per week | |
// 1.4625 - Exercising 5 times per week | |
// 1.550 - Exercising Daily | |
// 1.6375 - Exercising Intensely (45m+) 5 times per week | |
// 1.725 - Daily (intense) or twice daily regular exercise | |
// 1.9 - Daily exercise + physically demanding job | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment