Dog Years on .toLowcase error

let myAge = 16;

// My Age

let earlyYears = 2;

earlyYears *= 10.5;

//Early years math

let laterYears = myAge - 2;

//Later years My age - 2

laterYears * 4;

//Finding dog years

let myAgeInDogYears

laterYears += earlyYears = myAgeInDogYears;

//My age in dog years

let myName


/Lowercase name



console.log(laterYears + earlyYears)


Output-only Terminal
/Lowercase name
SyntaxError: Unexpected identifier
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

It’s was the answer in hints, everything else was right at least I think

The specific SyntaxError is because you need two forward slashes for a comment,

/Lowercase name

// Lowercase name

There are also a number of other issues with your code such as:

laterYears * 4; // What is this supposed to do without assignment to a variable?

let myAgeInDogYears // Do you just want to declare this or initialize it as well?

laterYears += earlyYears = myAgeInDogYears; // What is this supposed to do?

let myName // Declaration without initialization

'Andy'.toLowerCase(); // Do you assign the result to any variable?

To preserve code formatting in forum posts, see: How do I format code in my posts?

1 Like

I don’t understand, what you mean about declaring variables or initializing them, Everything else I understand so. Thanks

laterYears * 4;

The above statement multiplies the value stored in laterYears by 4 and then throws away the result. The original value in laterYears is still unchanged. So, the above statement serves no purpose unless you either assign the result to a variable OR do something useful with the result.

let myAgeInDogYears
let myName

You are declaring these variables. That’s fine. But, then you have to do something useful with them. If they are going to be used in a statement or calculation, then at some stage you must assign some value to them.
For Example,

let x;
y  = x + 1;
console.log(y); // NaN (Not a Number)
// because you have used x in a calculation 
// before assigning any value to the variable. Therefore, x is undefined and 
// adding 1 to it results in NaN.

// You could either have declared & initialized the variable with a value e.g.
let x = 5;
y  = x + 1;
console.log(y); // 6

// OR you could have just declared the variable, but at some later stage
// you need to assign a value to this variable before 
// using it in any calculation e.g.
let x;
x = 5;
y  = x + 1;
console.log(y); // 6

In your code, you have declared the myAgeInDogYears and myName variables, but you haven’t assigned any values to these variables anywhere in your code.

1 Like