Created
December 1, 2021 05:32
-
-
Save dillonchr/0d2f9cd14985e45757dd1bdbdcfd3b5c to your computer and use it in GitHub Desktop.
water weight
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
(function(weight) { | |
// how much water weighs per gallon | |
const WATER_WEIGHT_IN_POUNDS_PER_GALLON = 8.34; | |
// how much of the body is made of water | |
const WATER_PERCENTAGE_IN_BODY = 0.6; | |
function getGallonsOfWater(weight) { | |
return weight * WATER_PERCENTAGE_IN_BODY / WATER_WEIGHT_IN_POUNDS_PER_GALLON; | |
} | |
function getPoundsFromGallons(gallons) { | |
// since water is 60%, we need to figure out the other 40% | |
// so we just find one third of 60% (20%) and then double that | |
// to find 40% and add the two together to uncover what the original | |
// weight was | |
const oneThird = gallons / 3; | |
return (gallons + (oneThird * 2)) * WATER_WEIGHT_IN_POUNDS_PER_GALLON; | |
} | |
console.clear(); | |
console.log({ | |
weight, | |
gallons: getGallonsOfWater(weight), | |
andBack: getPoundsFromGallons(getGallonsOfWater(weight)) | |
}); | |
} | |
)(200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment