Skip to content

Instantly share code, notes, and snippets.

@Azeirah
Last active December 26, 2021 21:42
Show Gist options
  • Save Azeirah/41001640a79904177d78a17598c03de0 to your computer and use it in GitHub Desktop.
Save Azeirah/41001640a79904177d78a17598c03de0 to your computer and use it in GitHub Desktop.
Tea bitterness calculator
/**
* 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