-
Notifications
You must be signed in to change notification settings - Fork 29
js-HW #33
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
base: master
Are you sure you want to change the base?
js-HW #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//賴彥嘉 | ||
//getBMI | ||
function getBMI(height, weight){ | ||
return weight/(height*height); | ||
} | ||
console.log(getBMI(1.88, 74)); | ||
// getMessage | ||
var message ; | ||
function getMessage(height, weight){ | ||
return weight/(height*height); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果是寫這樣的話,getMessage函式不就跟getBMI功能一樣了? |
||
} | ||
var bmi= getMessage(1.7,74) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 直接 |
||
if(bmi<18.5){ | ||
message = '過輕';} | ||
else if(bmi>24){ | ||
message='過重' } | ||
else{ | ||
message='正常'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 13~18行應該放到getMessage函式中判斷,每個判斷都要return一個訊息,例如:
|
||
console.log(message); // | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//賴彥嘉 | ||
//getBMI | ||
function getBMI(height, weight){ | ||
return weight/(height*height); | ||
} | ||
console.log(getBMI(1.88, 74)); | ||
// getMessage | ||
var message ; | ||
function getMessage(height, weight){ | ||
return weight/(height*height); | ||
} | ||
var bmi= getMessage(1.7,74) | ||
if(bmi<18.5){ | ||
message = '過輕';} | ||
else if(bmi>24){ | ||
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.
如果已經有用return就可以不用再透過message存訊息了。