Skip to content

Instantly share code, notes, and snippets.

@sayham-sjb
Last active June 28, 2018 03:48
Show Gist options
  • Save sayham-sjb/3a1b3598cfd563688ac85f0e9c0f79c6 to your computer and use it in GitHub Desktop.
Save sayham-sjb/3a1b3598cfd563688ac85f0e9c0f79c6 to your computer and use it in GitHub Desktop.
DogYearCalculator #js #VS
function HumanDogYears(form) {
var HumanYears = form.inYears.value;
if (HumanYears >= 21) {
dy = (HumanYears - 21) / 4 + 2;
} else {
dy = HumanYears / 10.5;
}
var hdy = 0;
if (HumanYears >= 2) {
hdy = 21 + ((HumanYears - 2) * 4);
} else {
hdy = HumanYears * 10.5;
}
form.DogYears.value = Math.round(dy * 100) / 100;
form.HumanYears.value = Math.round(hdy * 100) / 100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment