Dog years, please review this

//This is my human age

const myAge=40;

//this is early year variale

let earlyYears=2;

earlyYears*=10.5;

//lateryears

let laterYears=myAge-2;

laterYears*=4;

//logging early and later years

console.log(earlyYears);

console.log(laterYears);

// My age in dog years

myAgeinDogYears=earlyYears+laterYears;

// User name

let name=‘Julie’;

let myName=name.toLowerCase();

//logging Name and age in human and dog years

console.log( My name is ${myName}. I am ${myAge} years old in human years which is ${myAgeinDogYears} years old in dog years. );

There are a couple things I saw. Currently this code won’t run, as their is an error with you last console.log(), try looking at how you are trying to log somethings. I can guess you want to log a template literal, so how do you define a template literal?

The other thing I noticed was a logical error. What happens if the user is only 1 year old? I don’t know if they’ve already covered logical operators at this point, but if they have I’d recommend adding an if gate to see if the person is 2 or older before working on the earlyYears variable.

All in all you are very close. Well done!! :slightly_smiling_face:

1 Like

Isn’t the last console.log() correctly formatted for a template literal? The back ticks just create this style of text in the forums?

1 Like
//This is my human age

const myAge=40;

//this is early year variale

let earlyYears=2;

earlyYears*=10.5;

//lateryears
if(myAge>=2)
{
  let laterYears=myAge-2;
  laterYears*=4;
  //logging early and later years
  console.log(earlyYears);
  console.log(laterYears);
  // My age in dog years
  myAgeinDogYears=earlyYears+laterYears;
  // User name
  let name="Julie";
  let myName=name.toLowerCase();
  //logging Name and age in human and dog years
  console.log(`My name is ${myName}. I am ${myAge} years old in human years which is ${myAgeinDogYears}years old in dog years.`);
}

else
{
 console.log(`You are only ${myAge} year old`);
}

I have changed it now, is this acceptable?

1 Like

:man_facepalming: Whoops, missed that…

1 Like

Beautifully done!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.