-
Notifications
You must be signed in to change notification settings - Fork 29
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
js-HW #33
base: master
Are you sure you want to change the base?
js-HW #33
Conversation
else if(bmi>24){ | ||
message='過重' } | ||
else{ | ||
message='正常'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
13~18行應該放到getMessage函式中判斷,每個判斷都要return一個訊息,例如:
if(bmi<18.5){
return "過輕";
}
} | ||
console.log(getBMI(1.88, 74)); | ||
// getMessage | ||
var message ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果已經有用return就可以不用再透過message存訊息了。
// getMessage | ||
var message ; | ||
function getMessage(height, weight){ | ||
return weight/(height*height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是寫這樣的話,getMessage函式不就跟getBMI功能一樣了?
function getMessage(height, weight){ | ||
return weight/(height*height); | ||
} | ||
var bmi= getMessage(1.7,74) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接bmi=getBMI(height,weight);
取得BMI值就好,
message='過重' } | ||
else{ | ||
message='正常'} | ||
console.log(message); // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(getMessage(1.7,74));
印出函式結果就可以了
No description provided.