Skip to content

add js practice #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions js-basic-practice/index.js
Original file line number Diff line number Diff line change
@@ -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);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

作業要求是希望有2個結果,所以應該要再呼叫getBMI(1.7,60);印出BMI數值噢