Dog Years

Another example using all the previous concepts in this chapter:

// Setting my age to a variable
let myAge = 12;

// Setting temp value
let earlyYears = 2;


earlyYears *= 10.5;

let laterYears = myAge - 2;


laterYears *= 4;

// Checking the values
console.log(earlyYears);
console.log(laterYears);


let myAgeInDogYears = earlyYears + laterYears;

// Setting a name to a variable
let myName = 'Johnson'.toLowerCase();

// Printing down a statement with my age in human years and my age in dog years
console.log(`My name is ${myName}. I am ${myAge} years old in human years which is ${myAgeInDogYears} years old in dog years.`);

Last updated