Open
Conversation
Evafly
suggested changes
Aug 4, 2017
2017-緣-casper_cheng.md
Outdated
There was a problem hiding this comment.
作業要求是要使用函式回傳,這樣是直接輸出結果,並沒有回傳
所以建議寫法:
var bmi="BMI:"+weight/((height/100)*(height/100)); //宣告一個變數,將計算結果傳入參數
如果想要斷行顯示身高體重以及BMI,可以先宣告一個變數裝進去並使用/n斷行再回傳
var str="height:"+height+"/nweight"+weight+"/nBMI:"+bmi;
return str;
2017-緣-casper_cheng.md
Outdated
2017-緣-casper_cheng.md
Outdated
2017-緣-casper_cheng.md
Outdated
2017-緣-casper_cheng.md
Outdated
|
下次還是上傳JS檔比較好歐^^ |
Evafly
reviewed
Aug 4, 2017
2017-緣-casper_cheng.md
Outdated
There was a problem hiding this comment.
這裡可以直接用 var bmi=getBMI(height,weight);就好囉
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.
function getBMI(height,weight){
console.log("height:"+height);
console.log("weight:"+weight);
console.log("BMI:"+weight/((height/100)*(height/100)));
}
getBMI(172,64);
function getMessage(height,weight)
{
var bmi = weight/((height/100)*(height/100));
console.log("height:"+height);
console.log("weight:"+weight);
if (bmi > 25){console.log("fat"); }
if (bmi > 18 && bmi <25){console.log("good"); }
if (bmi > 10 && bmi <18){ console.log("slim"); }
}
getMessage(172,80);