My age in dog years isn't right :0


#1

I'm working on the Learn Javascript course, and am having trouble with the Dog Years exercise. My code is giving a different result every time, even if I input the same valuable for the starting variable (my age).

this is what i have for the code:
firstYears = (2 * 10.5);
laterYears = ((myAge - 2) * 4);
myAgeInDogYears = (firstYears + laterYears);
console.log (myAgeInDogYears);
var myAge = prompt('What is your age?');

And then I'm putting the same value into the pop-up window every time and getting a different result. I think it might be a bug, but this is my first javascript course and i could be doing something wrong!


#2

This line should be first, not last. myAge is undefined in the above (on first run).


#3

Thank you!! I didn't know that the order mattered, so that's helpful feedback! :smiley:


#5