-
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
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,21 @@ | ||
//黃佳晨 | ||
var getBMI = function(weight, height){ | ||
return weight/((height/100)*(height/100)); | ||
|
||
} | ||
getBMI(65,171); | ||
var BMI = getBMI(65,171); | ||
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. 這邊先不要存入變數,因為這樣下面使用的BMI並沒有用到getMessage函式傳入的參數 |
||
console.log('BMI: '+BMI); | ||
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. 那這邊就先改成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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 這邊就可以宣告 |
||
if(BMI<18.5) | ||
console.log('體重過輕'); | ||
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. 這樣是直接輸出,沒有做回傳的動作 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. 直接 |
||
else if(BMI<24&&BMI>=18.5) | ||
console.log('正常範圍'); | ||
else if(BMI>=24&&BMI<30) | ||
console.log('過重'); | ||
} | ||
|
||
getMessage(65,171); | ||
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. 將函式中return的結果在這裡log出來 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. 這裡再console.log(getMessage(65,171));就好囉 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "ex03", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node demo.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
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.
這行不需要