Skip to content

Instantly share code, notes, and snippets.

@brettvaida
Last active November 2, 2020 14:15
Show Gist options
  • Select an option

  • Save brettvaida/6d4e9c1b95bc6116be9f4f8a5211f5d9 to your computer and use it in GitHub Desktop.

Select an option

Save brettvaida/6d4e9c1b95bc6116be9f4f8a5211f5d9 to your computer and use it in GitHub Desktop.
human-age-to-dog-years.js
// Defining my age
let myAge = 31;
// Defining early years. The first two human years of a dog's life count as 10.5 dog years each
let earlyYears = 2;
earlyYears *= 10.5;
// Defining later years. Each human year following counts as 4 dog years
let laterYears = myAge - 2;
laterYears *= 4;
// Calculating my age in dog years
let myAgeInDogYears = earlyYears + laterYears;
// Defining my name and converting to lowercase
const myName = "Brett";
myName.toLowerCase();
// Displaying my name and age in dog years
console.log(`My name is ${myName}. I am ${myAgeInDogYears} years old in dog years.`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment