-
Notifications
You must be signed in to change notification settings - Fork 29
BMI 計算機 #15
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?
BMI 計算機 #15
Conversation
|
||
var getMessage = function(weight,height) | ||
{ | ||
getBMI(weight,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.
這行也不需要
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.
這邊就可以宣告 var BMI=getBMI(weight,height);
了,這樣就有使用到傳入的參數了
return weight/((height/100)*(height/100)); | ||
|
||
} | ||
getBMI(65,171); |
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.
這行不需要
{ | ||
getBMI(weight,height); | ||
if(BMI<18.5) | ||
console.log('體重過輕'); |
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訊息
再到函式外面log結果
console.log('過重'); | ||
} | ||
|
||
getMessage(65,171); |
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的結果在這裡log出來
console.log(getMessage(65,171));
|
||
} | ||
getBMI(65,171); | ||
var BMI = getBMI(65,171); |
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並沒有用到getMessage函式傳入的參數
} | ||
getBMI(65,171); | ||
var BMI = getBMI(65,171); | ||
console.log('BMI: '+BMI); |
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('BMI:'+getBMI(65,171));
|
||
var getMessage = function(weight,height) | ||
{ | ||
getBMI(weight,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.
這邊就可以宣告 var BMI=getBMI(weight,height);
了,這樣就有使用到傳入的參數了
{ | ||
getBMI(weight,height); | ||
if(BMI<18.5) | ||
console.log('體重過輕'); |
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 "要顯示的結果"
就可以了
console.log('過重'); | ||
} | ||
|
||
getMessage(65,171); |
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(65,171));就好囉
No description provided.