Skip to content

2017-Overdeadline-ostrich2821 js-homework #28

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
21 changes: 21 additions & 0 deletions 2017-Overdeadline-ostrich2821.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function getBMI(height,weight){
Copy link

Choose a reason for hiding this comment

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

記得//你的大名

var myBMI = weight / (height * height);

return myBMI;
}

getBMI(1.5, 50);

var BMI = getBMI(1.5, 50);

function getMessage(){
Copy link

Choose a reason for hiding this comment

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

因為作業的題目是getMessage函式可以傳入height與weight,所以這邊建議把bmi放到函式內,並讓getMessage傳入height與weight兩個參數,然後在getMessage內呼叫getBMI,例如:

function getMessage(height,weight){
    var BMI=getBMI(height,weight);
        ......
}

if ( BMI < 18.5 ){
console.log('體重過輕');
}else if(18.5 <= BMI && 24 > BMI){
console.log('正常範圍');
}else{
console.log('異常範圍');
Copy link

Choose a reason for hiding this comment

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

判斷完return "要顯示的訊息"就可以了

}
}

getMessage();
Copy link

Choose a reason for hiding this comment

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

這邊再console.log(getMessage(1.5,50));印出結果就好