Open
Conversation
joan45r
reviewed
Aug 4, 2017
|
|
||
| var getMessage = function(weight,height) | ||
| { | ||
| getBMI(weight,height); |
There was a problem hiding this comment.
這邊就可以宣告 var BMI=getBMI(weight,height);了,這樣就有使用到傳入的參數了
| return weight/((height/100)*(height/100)); | ||
|
|
||
| } | ||
| getBMI(65,171); |
joan45r
reviewed
Aug 4, 2017
| { | ||
| getBMI(weight,height); | ||
| if(BMI<18.5) | ||
| console.log('體重過輕'); |
There was a problem hiding this comment.
這樣是直接輸出,沒有做回傳的動作
作業題目是要函數回傳,所以先return訊息
再到函式外面log結果
joan45r
reviewed
Aug 4, 2017
| console.log('過重'); | ||
| } | ||
|
|
||
| getMessage(65,171); No newline at end of file |
There was a problem hiding this comment.
將函式中return的結果在這裡log出來
console.log(getMessage(65,171));
Evafly
reviewed
Aug 4, 2017
|
|
||
| } | ||
| getBMI(65,171); | ||
| var BMI = getBMI(65,171); |
There was a problem hiding this comment.
這邊先不要存入變數,因為這樣下面使用的BMI並沒有用到getMessage函式傳入的參數
| } | ||
| getBMI(65,171); | ||
| var BMI = getBMI(65,171); | ||
| console.log('BMI: '+BMI); |
There was a problem hiding this comment.
那這邊就先改成console.log('BMI:'+getBMI(65,171));
|
|
||
| var getMessage = function(weight,height) | ||
| { | ||
| getBMI(weight,height); |
There was a problem hiding this comment.
這邊就可以宣告 var BMI=getBMI(weight,height);了,這樣就有使用到傳入的參數了
| { | ||
| getBMI(weight,height); | ||
| if(BMI<18.5) | ||
| console.log('體重過輕'); |
| console.log('過重'); | ||
| } | ||
|
|
||
| getMessage(65,171); No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.