JavaScript Syntax, Part I - Dog Years

Hi guys,

In the objective described above, I assigned the value -= 2 to the variable myAge as recommended. However, due to the use of console.log() to print myAge in human years the value printed was myAge -= 2, my age was 2 years short. To correct the value of myAge to my real age I wrote a line before console.log() to reassign myAge +=2. The description of the task was missing this step or I am missing something?

Link to my code here below.

Could you provide a link to the lesson, please?

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-i/modules/fecp-learn-javascript-syntax-introduction/projects/dog-years-javascript

You may have missed the reason why you should subtract 2 years from your age: Your age is split in two parts: 2 years + the rest of your life because a dog doesn’t have the same process of aging. In the first two years it ages faster. You find that explanation in the introduction to the lesson.

I understood that.
The thing is, the new value from myAge is my current age -2.
So when the value from myAge gets printed to the console, the value is not my age. It’s my age -2.
To print my age correctly on the console, I had to reassign myAge with += 2. This procedure didn’t get listed in the objective’s tasks.
My question is if I got something wrong or not.

Step 4, right? You missed this instruction:

Set the result equal to a variable called laterYears .

Reassigning your age - 2 to the variable myAge is not what you’re asked to do.

Please, take a look at lines 4 and 5 of my code.
I didn’t miss anything,
I am talking about the value of the myAge variable.
In the end, following the tasks, the value is my age -2.

This is a reassignment:

It is the same (in short) as if you wrote:

myAge = myAge - 2;

which you aren’t asked to do.

You should do this instead:

let laterYears = myAge - 2;

So, to be more precise: You did not literally miss anything but you did too much.

2 Likes

Now I’ve understood.
Thank you very much for your answer and time.

1 Like