Created
November 15, 2014 10:48
-
-
Save f3r/f0e4b49cf47cdcd1c55b to your computer and use it in GitHub Desktop.
bmi calculator
This file contains 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
cal_bmi = (weight_kg, height_cm) -> | |
height_m = height_cm/100 | |
bmi = weight_kg / (height_m * height_m) | |
f_bmi = Math.floor(bmi) | |
diff = Math.round((bmi - f_bmi) * 10) | |
if diff == 10 # Need to bump up the whole thing instead | |
f_bmi += 1 | |
diff = 0 | |
return "#{f_bmi}.#{diff}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment