Last active
December 26, 2021 21:42
-
-
Save Azeirah/41001640a79904177d78a17598c03de0 to your computer and use it in GitHub Desktop.
Tea bitterness 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
/** | |
* tea_serving is a Natural number. | |
* 1 represents 1 teaspoon | |
* water_temperature is in degrees | |
* tea_type is of enum TEA_TYPE | |
* steeping time is in minutes | |
*/ | |
function bitterness(tea_serving, water_temperature, tea_type, steeping_time) { | |
let tooHotBitternessMultiplier = 1; | |
let teaTypeGroundBitterness = 1; | |
if (teaIsLight(tea_type)) { | |
teaTypeGroundBitterness = 1; | |
} else if (teaIsDark(tea_type)) { | |
teaTypeGroundBitterness = 1.5; | |
} | |
if (!waterTemperatureIsRightForTea(tea_type, water_temperature)) { | |
tooHotBiternessMultiplier = 1.5; | |
} | |
return steeping_time * Math.max(0.5, tea_serving) * tooHotBiternessMultiplier * teaTypeGroundBitterness; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment