Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calorieCalculator(input) {
- let gender = input[0];
- let weight = Number(input[1]);
- let height = Number(input[2]);
- let age = Number(input[3]);
- let physicalActivity = input[4];
- let basalMetabolicRate;
- let coefficientActivity;
- if (gender == 'm') {
- basalMetabolicRate = 66 + weight * 13.7 + height * 500 - 6.8 * age;
- } else {
- basalMetabolicRate = 655 + weight * 9.6 + height * 180 - 4.7 * age;
- }
- if (physicalActivity == "sedentary") {
- coefficientActivity = 1.2;
- } else if (physicalActivity == "lightly active") {
- coefficientActivity = 1.375;
- } else if (physicalActivity == "moderately active") {
- coefficientActivity = 1.55;
- } else {
- coefficientActivity = 1.725;
- }
- let calories = basalMetabolicRate * coefficientActivity;
- console.log(`To maintain your current weight you will need ${Math.ceil(calories)} calories per day.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement