From 4743f0504b1def421204d285fa4a771382d1c022 Mon Sep 17 00:00:00 2001 From: william Date: Thu, 20 Jul 2017 04:08:38 +0000 Subject: [PATCH] add js practice --- js-basic-practice/index.js | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 js-basic-practice/index.js diff --git a/js-basic-practice/index.js b/js-basic-practice/index.js new file mode 100644 index 0000000..1170da5 --- /dev/null +++ b/js-basic-practice/index.js @@ -0,0 +1,39 @@ +// 陳景斌 + +function getBMI(height, weight) { + var bmi = weight / (height*height); + return bmi; +} + +function getMessage(height, weight) { + var bmi = getBMI(height, weight); + if ( bmi < 18) { + return '過輕:BMI<18' + } + + if (bmi >= 18 || bmi < 24) { + return '正常:18.5≦BMI<24' + } + + if (bmi >= 24 || bmi < 27) { + return '過重:24≦BMI<27' + } + + if (bmi >= 27 || bmi < 30) { + return '輕度肥胖:27≦BMI<30' + } + + if (bmi >= 30 || bmi < 35) { + return '中度肥胖:30≦BMI<35' + } + + if (bmi >= 35 ) { + return '重度肥胖:BMI≧35' + } +} + +getMessage(1.7,60); + + + +