Vili
Vili

Reputation: 113

Capitalizing values

I'm going to have to apologize for how simple this question is going to be. I am a literally on Chapter 2 trying to learn javascript, and only just preparing myself for what is to come.

My questions specifically refers to Chapter 2 of Eloquent Javascript's section on Variables. In the websites JS sandbox it uses the example:

var luigisDebt = 140;
luigisDebt = luigisDebt - 35;
console.log(luigisDebt);
// → 105
105

Got it no problem! Test around a bit more:

var luigisDebt = 140;
luigisDebt = luigisDebt - 35;
luigisDebt = luigisDebt - 5
console.log(luigisDebt);
100

However if I mess around with the capitalization like this:

var luigisDebt = 140;
luigisDebt = luigisDebt - 35;
luigisDebt = luigisdebt - 5
console.log(luigisDebt);
95

My output becomes incorrect with 95, instead of the correct 100.

Thanks to other posts I've learned about camelCase, constructer functions and PascalCase. But still can't figure out why my output changes with Upper and Lower case?

Upvotes: 0

Views: 55

Answers (1)

Prasanna
Prasanna

Reputation: 1751

luigisdebt is not defined in your code, it should answer 105. define this before using it.

Upvotes: 1

Related Questions