-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmiFunctions.js
87 lines (71 loc) · 2.01 KB
/
bmiFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function bmiCalc(cm, kg, calculateWHR, gender, waist, hip, failcallback, successcallback) {
var m = (parseInt(cm, 10) / 100);
var kg = kg;
var calculateWHR = calculateWHR;
if (m == 0 || isNaN(m)) {
// console.log("fanget")
failcallback(undefined)
// res.redirect("/");
} else {
var bmi = (kg / (m * m));
var bmiGroup
if (bmi < 18.5)
bmiGroup = 'Underweight'
else if (bmi < 25)
bmiGroup = 'Healthy weight'
else if (bmi < 30)
bmiGroup = 'Overweight'
else
bmiGroup = 'Obese'
// console.log(bmiGroup)
var whr
var whrClassification
if (calculateWHR) {
whr = waist / hip
if (gender == "male") {
if (whr < 0.9)
whrClassification = 'normal weight'
else if (whr < 1)
whrClassification = 'over-weight'
else
whrClassification = 'obesity'
}
else {//female
if (whr < 0.8)
whrClassification = 'normal weight'
else if (whr < 0.85)
whrClassification = 'over-weight'
else
whrClassification = 'obesity'
}
}
var completeObj = {
bmi: bmi,
bmiGroup: bmiGroup,
whr: whr,
whrClassification: whrClassification
}
successcallback(completeObj)
// res.render("pages/result", {
// bmi: bmi,
// bmiGroup: bmiGroup,
// whr: whr,
// whrClassification: whrClassification
// });
}
}
function calcBmi(weight, height) {
}
function getBmiGroup(bmi) {
}
function calcWhr(waist, hip) {
}
function getwhrClassification(whr) {
}
module.exports = {
calcBmi: calcBmi,
getBmiGroup: getBmiGroup,
calcWhr: calcWhr,
getwhrClassification: getwhrClassification,
bmiCalc: bmiCalc
}